0

After 3 whole days of testing, researching and failing I need your help please on this one.

I have this HTML form

<form action="upload.php" method="POST" enctype="multipart/form-data" target="upload_target" >
    <input type="hidden" name='<?php echo ini_get("session.upload_progress.name"); ?>"' value="myUploadProgress">
    <input type="file" name="myfile" id="file1" style="display:none">
    <button id="browse-button">Browse</button>
    <input id="update-button" class="disabled" type="submit" name="submitBtn" value="Update" />
</form>

and I separated my php in to 2 steps:

  1. upload.php - posting the form

    <?php
        session_start();
    
        getcwd().DIRECTORY_SEPARATOR;
    
        chdir('/tmp');
    
        $destination_path = getcwd();
    
        $result = 0;
    
        $target_path = $destination_path . '/' .basename( $_FILES['myfile']['name']);
    
        if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
            $result = 1;
        }
    
        sleep(1);
    ?>
    
  2. upload_status.php - fired by an ajax request on 1000ms interval

    <?php
    
        print_r($_SESSION);
    
    ?>
    

for some reason I keep getting $_SESSION as empty and I expected to get $_SESSION["upload_progress_myUploadProgress"] (or something else) as array of vars of my current upload.

Things that I have checked and already in my php.ini

  • file_uploads: On
  • post_max_size: 2G
  • upload_max_filesize: 2G
  • output_buffering: off
  • session.upload_progress.cleanup: On
  • session.upload_progress.enabled: On
  • session.upload_progress.freq: 1%
  • session.upload_progress.min_freq: 1
  • session.upload_progress.name: PHP_SESSION_UPLOAD_PROGRESS
  • session.upload_progress.prefix: upload_progress_
itay101
  • 53
  • 1
  • 5
  • As I understood from [PHP Documentation](http://php.net/manual/en/session.upload-progress.php) I should get the upload progress as a key in session while the file is uploading. I don't think I need to do any set for $_SESSION – itay101 Nov 14 '14 at 09:31
  • Ah i see, well did you read the comments below at the link you provided: The web server's request buffering has to be disabled or this feature doesn't work, when your webserver is runnig PHP via FastCGI etc, etc. What php version are you using? – Jonathan Römer Nov 14 '14 at 09:34
  • It is currently off, sorry I didn't mention it in my question – itay101 Nov 14 '14 at 09:39
  • This may help : http://stackoverflow.com/questions/21703081/php-upload-progress-in-php-5-4-is-not-working-session-variables-not-set?rq=1 – Jonathan Römer Nov 14 '14 at 09:41
  • How can I check if i'm using PHP via FastCGI ? – itay101 Nov 14 '14 at 09:46
  • Check this : http://stackoverflow.com/questions/609044/how-to-know-for-sure-if-fastcgi-is-being-used-to-run-php-scripts – Jonathan Römer Nov 14 '14 at 09:58
  • ok, everything is correct according to [this link](http://stackoverflow.com/questions/21703081/php-upload-progress-in-php-5-4-is-not-working-session-variables-not-set?rq=1) you gave me, weird!!! – itay101 Nov 14 '14 at 10:00
  • 1
    Try adding `session_start();` in upload_status.php before the `print_r` – Jonathan Römer Nov 14 '14 at 10:17

0 Answers0