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_
8
  • As I understood from PHP Documentation 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 Commented Nov 14, 2014 at 9: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? Commented Nov 14, 2014 at 9:34
  • It is currently off, sorry I didn't mention it in my question Commented Nov 14, 2014 at 9:39
  • This may help : stackoverflow.com/questions/21703081/… Commented Nov 14, 2014 at 9:41
  • 1
    Try adding session_start(); in upload_status.php before the print_r Commented Nov 14, 2014 at 10:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.