donglu9445 2013-09-20 10:04
浏览 43
已采纳

PHP会话上传进度和同步上传

The PHP documentation doesn't explain what happens when there are two files being uploaded at the same time within the same session (two uploads running in two tabs of a browser).

Is there any way to track the progress of both uploads? Is the first upload status lost when the second one starts?

Thanks!

  • 写回答

2条回答 默认 最新

  • dsgwii4867 2014-01-04 22:32
    关注

    Yes, it is possible to monitor the status on two different uploads in different tabs using PHP's Session Upload Progress feature. All you need to do is make the upload progress name different on both forms by changing the value="" parameter of the hidden upload progress name field.

    For example, the upload form for tab 1 could look as follows:

    <form action="upload.php" method="POST" enctype="multipart/form-data">
    
    <input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="tab1">
    <!-- notice the value="tab1" above -->
    
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000">
    <input type="file" name="myUploadName" />
    <input type="submit" />
    </form>
    

    Then, the upload form for tab 2 could look as follows:

    <form action="upload.php" method="POST" enctype="multipart/form-data">
    
    <input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="tab2">
    <!-- notice the value="tab2" above -->
    
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000">
    <input type="file" name="myUploadName" />
    <input type="submit" />
    </form>
    

    Now that you have created two different upload progress sessions, you can get the progress data on the PHP side as follows:

    $_SESSION['upload_progress_tab1'] // Progress data for tab 1
    $_SESSION['upload_progress_tab2'] // Progress data for tab 2
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题