2

this question was asked milions of times, but I'm FIGHTING with this problem since three days, and I'm totaly confused.

I can't force PHP to save details about uploded files in $_SESSION (http://www.php.net/manual/en/session.upload-progress.php). All I can get is empty session.

The most simple example of my code:

index.php

<?php session_start(); $_SESSION['test'] = 'TEST'; ?> <form action="index.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="123" /> <input type="file" name="file1" /> <input type="file" name="file2" /> <input type="submit" /> </form> <?php print_r($_SESSION); ?> 

result - after clicking submit ;)

Array ( [test] => TEST ) // nothing more... 

php -i | grep upload_progress

session.upload_progress.cleanup => Off => Off session.upload_progress.enabled => On => On session.upload_progress.freq => 1% => 1% session.upload_progress.min_freq => 1 => 1 session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS session.upload_progress.prefix => upload_progress_ => upload_progress_ 

php -i | grep size

post_max_size => 2G => 2G realpath_cache_size => 16K => 16K upload_max_filesize => 2G => 2G Command buffer size => 4096 Read buffer size => 32768 

  • The file size of file beeing uploaded (local host): 2 x 1.5GB
  • Time of execution: 8 seconds
  • I'm using Gentoo linux with php 5.5.12, Apache 2 compiled without Fast CGI support.

Bibliography:

https://stackoverflow.com/a/21851657/1125465 - as far as I'm concerned each of these are OK in my configuration.

https://stackoverflow.com/a/13186859/1125465 - tried all the scripts, and all the versions. SESSION superglobal is empty for each one.

https://stackoverflow.com/a/11485170/1125465 - As I commented this answer... Is not an answer.

Please, help! I'm starting to loose my mind. Best regards.


UPDATE phpinfo() result screenshot:

phpinfo() screenshot

It is worth notice that files are being uploaded to tmp directory, without any troubles.

2
  • What version of PHP are you using? Commented Jun 2, 2014 at 11:59
  • PHP 5.5.12, Apache 2 compiled without Fast CGI support. (to deleted comment: PHP should init $_SESSION["upload_progress_123"] automaticaly. See link in my question: php.net/manual/en/session.upload-progress.php). Thx for interest :). Commented Jun 2, 2014 at 12:00

2 Answers 2

2

I had exactly the same issue. Solution was to simply replace the handler from FastCGI to PHP-FPM. Also works on Mod PHP but it doesn't work on FastCGI even with the new PHP.

Sign up to request clarification or add additional context in comments.

3 Comments

WOW. One recompilation on Gentoo with different USE flags, and everything runs as rocket. Thx VERY much, even more as this question is so old, +1 and of course accepted.
@Sebastian-Placento - This is likewise driving me crazy! I have an installation of PHP 5.4.40 / Apache 2.4.12 and I don't think FastCGI is enabled in either Apache or PHP (phpinfo(); shows Server API = Apache 2.0 Handler). I save the output of print_r($_SESSION,true); to a file on the server and it always returns array( ) ie. an empty array. I've worked 24 hours straight trying to understand this problem and still have no idea what to do so if you do have any advice for me I would greatly appreciate it!
@Sebastijan-Placento - never mind thank you, I have resolved the issue. The problem was that the server had secure cookies enabled and I was testing using http:// so the browser was refusing to send it's cookie, causing the server to think each call was a new session.
2

I think you missed the most important part of the documentation

QUOTE

When the session.upload_progress.enabled INI option is enabled, PHP will be able to track the upload progress of individual files being uploaded. This information isn't particularly useful for the actual upload request itself, but during the file upload an application can send a POST request to a separate endpoint (via XHR for example) to check the status.

This means that the session information is only available when the upload is in progress.

You therefore have to write a bit of javascript in the upload page, to fire another script on the server to query this information and return it to the javascript so that you can manipulate a slider or whatever mechanism you are using to show the user the progress of the upload. Once the upload is completed the info in the session will be scrapped.

7 Comments

Thx for your answer. However, I was trying to get this $_SESSION using AJAX and every other method for "live view". To make my post clear, and short, I only pasted the smallest working example. When You will take a look at my session settings, you will notice that session.upload_progress.cleanup => Off => Off. According to manual: php.net/manual/en/…, it should be there even after upload. But SESSION is empty even during the upload (checked via AJAX, iframe, Jquery GET method, load method,...). Thx for your reply.
PS. I think noone will downvote your answer, as it can be useful in other cases, so if you can, please do not erase it :). +1 from me, but question is still opened I think...
Ok, in that case are you sure that you have edited the correct php.ini file. Have you checked using phpinfo();?
Yes Sir! You can check my updated question with screen. I will do everything what I can do help solving this problem. I was reading the Gentoo PHP documentation / bug reports about this one, and found nothing. Thx for your help. I think I'm just missing some detail. However I was trying with milions of different codes during last few days, and nothing worked.
@JacekKowalewski did you ever figure out this problem? I'm having the same problem...
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.