php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58138 APC Upload not working
Submitted: 2008-04-04 04:38 UTC Modified: 2011-09-18 13:17 UTC
From: pecl at neuveglise dot net Assigned: gopalv (profile)
Status: Closed Package: APC (PECL)
PHP Version: 5.2.0 OS: Debian Etch
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 + 44 = ?
Subscribe to this entry?

 
 [2008-04-04 04:38 UTC] pecl at neuveglise dot net
Description:
------------
File upload are not tracked with APC on Debian Etch (PHP 
Version 5.2.0-8+etch10)

phpinfo :

APC Support	enabled
Version	3.0.18
MMAP Support	Enabled
MMAP File Mask	no value
Locking type	pthread mutex Locks
Revision	$Revision: 3.154.2.2 $
Build Date	Apr 4 2008 10:22:31

Directive	Local Value	Master Value
apc.cache_by_default	On	On
apc.coredump_unmap	Off	Off
apc.enable_cli	Off	Off
apc.enabled	On	On
apc.file_update_protection	2	2
apc.filters	no value	no value
apc.gc_ttl	3600	3600
apc.include_once_override	Off	Off
apc.max_file_size	1M	1M
apc.mmap_file_mask	no value	no value
apc.num_files_hint	1000	1000
apc.report_autofilter	Off	Off
apc.rfc1867	On	On
apc.rfc1867_freq	0	0
apc.rfc1867_name	APC_UPLOAD_PROGRESS	
APC_UPLOAD_PROGRESS
apc.rfc1867_prefix	upload_	upload_
apc.shm_segments	1	1
apc.shm_size	30	30
apc.slam_defense	0	0
apc.stat	On	On
apc.stat_ctime	Off	Off
apc.ttl	0	0
apc.user_entries_hint	4096	4096
apc.user_ttl	0	0
apc.write_lock	On	On




Reproduce code:
---------------
<form enctype="multipart/form-data" target="tfrm" action="index.php" method="post" onsubmit="attendEnvoie();">
	<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo uniqid()?>">
	<input type="file" id="test_file" name="test_file"><br>
	<input type="submit" value="Upload!">
	<input type="button" onclick="annule();" value="Annule">
</form>

if (isset($_GET['progress_key'])) {
    $rep=apc_fetch('upload_'.$_GET['progress_key']);
    echo json_encode($rep);
    exit;



Expected result:
----------------
$rep to be filled with proper values

Actual result:
--------------
fals

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-05 04:10 UTC] pecl at neuveglise dot net
Ended up installing uploadprogress from pecl too. this on is 
working good so far :)
 [2008-04-06 01:07 UTC] rasmus@php.net
Works fine here on Debian.  Do you have another extension enabled that might be grabbing the upload hook?
 [2008-04-06 05:54 UTC] pecl at neuveglise dot net
Hi doesn't seems so since uploadprogress is working fine 
(after disabling apc.rfc1867 of course)

No /tmp/apc* file was created, whereas there is a upt_* with 
uploadprogress
 [2008-04-25 06:03 UTC] gernot at kunz dot co dot at
I have the same problem: same Debian, PHP, APC versions, same APC settings.

The progress bar works with SuSe Linux 10.3. but not with  Debian.
 [2008-04-25 16:15 UTC] gernot at kunz dot co dot at
I debugged this: the APC upload entry is created when the file upload is complete. Some forums mention mod_security or mod_suexec may be responsible for this behaviour. However, mod_security and mod_suexec are not enabled. PHP is a module. I also have a SuSe system - it is working there.
 [2008-04-26 01:47 UTC] rasmus@php.net
Suhosin could also get in the way if you have that installed.
 [2008-05-21 10:42 UTC] pecl at thibernet dot com
Same problem:

APC return infos only when the upload is completed.

More informations:

PHP Version 5.2.0-8+etch11

APC Support 	enabled
Version 	3.0.19
MMAP Support 	Enabled
MMAP File Mask 	no value
Locking type 	pthread mutex Locks
Revision 	$Revision: 3.154.2.5 $
Build Date 	May 21 2008 16:40:01

apc.cache_by_default	On	On
apc.coredump_unmap	Off	Off
apc.enable_cli	Off	Off
apc.enabled	On	On
apc.file_update_protection	2	2
apc.filters	no value	no value
apc.gc_ttl	3600	3600
apc.include_once_override	Off	Off
apc.max_file_size	1M	1M
apc.mmap_file_mask	no value	no value
apc.num_files_hint	1000	1000
apc.report_autofilter	Off	Off
apc.rfc1867	On	On
apc.rfc1867_freq	0	0
apc.rfc1867_name	APC_UPLOAD_PROGRESS	APC_UPLOAD_PROGRESS
apc.rfc1867_prefix	upload_	upload_
apc.shm_segments	1	1
apc.shm_size	30	30
apc.slam_defense	0	0
apc.stat	On	On
apc.stat_ctime	Off	Off
apc.ttl	0	0
apc.user_entries_hint	4096	4096
apc.user_ttl	0	0
apc.write_lock	On	On
 [2008-06-15 16:32 UTC] x2f0y at yahoo dot com
I'm not sure if this is the appropriate place to place this, but I am having what appears to be the exact same issue - only under the new Ubuntu 8.04.  Given the linkage between Ubuntu and Debian, I assume it's the same error.

I've worked with the same code for several months now, and everything was fine under Ubuntu 7.10.  Under 8.04, all versions of the script are not working.  //sigh//

I do have APC installed and enabled, and at the moment Suhosin  is incorporated.

Thoughts?
 [2008-08-28 03:45 UTC] gernot at kunz dot co dot at
Watch out for firewalls inspecting POST traffic! I disabled the firewall and the progress bar worked.

Apparently, the firewall swallowed up the POST traffic to inspect it, then released it in one piece to the server. Thus, the progress bar would remain at 0% until the upload was complete, then jump to 100% (which was not always observable).
 [2008-10-02 06:40 UTC] alexakaghost at rambler dot ru
Has somebody solved this problem?
 [2008-11-04 18:29 UTC] atistler at gmail dot com
Same exact problem. I can perform what ever troubleshooting is necessary.

Note: I am running a few php-cgi processes behind lighttpd.

APC Version	3.0.19
PHP Version	5.2.6

Runtime Settings
apc.cache_by_default	1
apc.coredump_unmap	0
apc.enable_cli	0
apc.enabled	1
apc.file_update_protection	2
apc.filters	
apc.gc_ttl	3600
apc.include_once_override	0
apc.max_file_size	1M
apc.mmap_file_mask	
apc.num_files_hint	1000
apc.report_autofilter	0
apc.rfc1867	1
apc.rfc1867_freq	0
apc.rfc1867_name	APC_UPLOAD_PROGRESS
apc.rfc1867_prefix	upload_
apc.shm_segments	1
apc.shm_size	64
apc.slam_defense	0
apc.stat	1
apc.stat_ctime	0
apc.ttl	0
apc.user_entries_hint	4096
apc.user_ttl	0
apc.write_lock	1
 [2008-11-05 13:29 UTC] atistler at gmail dot com
further testing..

I switched over to apache to test, same issue:

What happens is as follows:

1) I start polling apc every 100ms for the file upload status.  Obviously, the first few apc_fetch('upload_' . $id) return false which is fine.

2) I submit the upload ( through hidden iframe ) 200 milliseconds later.

3) It seems that only once the upload is complete, does apc_fetch('upload_' . $id) return back a valid upload status, where total === current, i.e. the upload is done ( as others have said above). 


Server version: Apache/2.0.52
Architecture:   32-bit
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
 [2009-02-18 05:06 UTC] kmrmtms at gmail dot com
Is there any solution for this problem?
 [2009-02-18 13:04 UTC] shire@php.net
What is the size of the file you are uploading?  

Does changing the rfc1867_freq setting change anything?  

Can you validate the test from localhost to make sure a firewall isn't getting in the way?
 [2009-04-05 23:27 UTC] shire@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2009-04-18 12:57 UTC] m5it at m5it dot org
I have the same problems!!
System: Ubuntu 8.04

it checks the file that i uploaded before file i am uploading right now. So it return $status['done'] at the first time.

print_r looks like this:
{"total":4037,"current":4037,"rate":63324372.0037,"filename":"rtor.rc","name":"myFile","temp_filename":"\/tmp\/phplNAPZm","cancel_upload":0,"done":1,"start_time":1240072203.55}

but it check rtor.rc but at the time i am uploading screenshoot.png for example.. :(

so the bug is stell here?
 [2009-04-20 16:03 UTC] shire@php.net
This sounds more like a coding issue to me.  Can you please paste a complete reproduction of your PHP code for both the HTML upload form and the status check?  Can you also send me all your apc.ini configuration options?  I'd also like you to verify your problem reproduces on the latest APC CVS code.
 [2009-04-27 15:11 UTC] gigi at reea dot net
Re: APC return infos only when the upload is completed.

Make sure you put the progress key input type hidden before the file input.
Like this:
<input id="progress_key" name="APC_UPLOAD_PROGRESS" type="hidden" value="<?php echo $progressKey;?>" />
<input name="file" id="file" type="file" />

I lost some hours because of this .....
 [2009-04-27 15:15 UTC] shire@php.net
Yes, unfortunately we have to have the hidden field first so we know to start collecting data for the file field following it.  I'll make this more obvious in the documentation ;-)
 [2009-05-17 18:01 UTC] php at bugsau dot org
Got the same problem, entry is created when the file upload is complete. Using lighttpd 1.4.22 (1 Thread), php5-cgi and php-apc or latest CVS code.

Upload:
----------
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="APC_UPLOAD_PROGRESS" value="<?php echo $unique_id?>" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File">
</form>
----------

Progress:
----------
<?php
  print_r(apc_fetch('upload_'.$_GET['progress_key']));
?>
----------

APC:
----------
Version 	3.1.2
MMAP Support 	Enabled
MMAP File Mask 	no value
Locking type 	pthread mutex Locks
Revision 	$Revision: 3.222 $
Build Date 	May 17 2009 21:43:51
...
apc.rfc1867	On
apc.rfc1867_freq	0
apc.rfc1867_name	APC_UPLOAD_PROGRESS
apc.rfc1867_prefix	upload_
...
----------
 [2009-06-05 01:05 UTC] jordan at gocubeco dot com
I'm having the same issue with APC not being able to track file uploads. I'm using Drupal's filefield module, which relies on APC and apc.rfc1867 to manage the progress bar.

My webserver is nginx/0.6.35 and PHP 5.2.6-3ubuntu4.1 is running under FASTCGI. My LEENIX is Ubuntu 9.10 server.

Here's the link to my Drupal Issue Report:
http://drupal.org/node/437254#comment-1659482
 [2009-06-05 01:07 UTC] jordan at gocubeco dot com
The issue seems to be that

$status = apc_fetch('upload_' . $key);

is always returning FALSE.
 [2009-11-09 09:55 UTC] ralf dot huebner at baseg dot de
I?ve same problem too!

And it?s seems to be the Firewall because in local network it works fine, but not from outside via WAN.

APC 3.1.2
PHP 5.2.9
 [2009-12-11 04:08 UTC] yvan dot taviaud at gmail dot com
You can see why right here:
http://forum.lighttpd.net/topic/79260

This is because lighttpd sends the whole POST data to PHP only once it's uploaded. So it sends ?false?, then it's okay when the file is transmitted. See the speed of sending: it's near infinity :-)

No solution but using lighttpd 1.5.0
 [2010-05-26 16:38 UTC] tim at vanillaforums dot com
I was running into the same issue:

OS X 10.6.3
Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 PHP/5.3.1
APC 3.1.3p1

Then I read that the APC_UPLOAD_PROGRESS input *MUST* come *BEFORE* the file input. Making that change solved all my issues instantly.

Try this, it works.
 [2010-07-07 08:35 UTC] napolean at gmail dot com
Wow unreal.. after a few hours of maddening trial and error, I stumbled upon Tims post above and it worked fine!

I cant believe it was something so simple.

Thanks Tim!
 [2010-07-13 07:26 UTC] gopalv82 at yahoo dot com
Alright, I shall put in a warning for the case where the form input is ordered that way.

Will close it once I've done that.

Cheers!
 [2010-07-13 08:25 UTC] gopalv82 at yahoo dot com
http://news.php.net/php.pecl.cvs/14428

There you go, a new warning for APC_UPLOAD_PROGRESS being behind the file upload.
 [2010-10-18 16:37 UTC] throwaway at indietorrent dot org
tim's suggestion from [2010-05-26 20:38 UTC] solved the problem for me, too.

The HTML form in its entirety appears as such:

<form name="formUploadFile" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<input type="hidden" name="MAX_FILE_SIZE" value="2000000000" />

<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progressKey" value="<?php echo uniqid(); ?>"/>

<input name="myUploadedFile" type="file" />

<input name="btnSubmit" type="submit" value="Upload File" />

</form>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 16:01:27 2024 UTC