|
|

05-08-2006, 02:20 PM
|
|
New Member
|
|
Join Date: May 2006
Posts: 9
|
|
Uploading files / tmp file creation
OK. I don't know if this is a bug in PHP / LSAPI / LSWS , but here goes:
When uploading a file via a form to a .php , php says it saves the file in /tmp/php<random> whatever, and if I do the following, it creates the new file "test1.move" correctly.
move_uploaded_file($_FILES['filename1']['tmp_name'],'/home/picgame/tmp/test1.move');
The problem is, the filename in [tmp_name] does not exist, so I am thinking instead of php SAVING the file to the upload_dir like it should be, it is storing it and accessing it from RAM.
For a script I am working on (upload progress) , I need to be able to read the size of the file from the filesystem before it is finished and after it is finished without having to use move_uploaded_file.
Anybody have ANY ideas why php is not saving the file /tmp/phpRandomID to the drive as it is being uploaded?
|

05-08-2006, 02:26 PM
|
|
Senior Member
|
|
Join Date: Nov 2004
Posts: 288
|
|
|
its only saving the file there once the upload is finished.
thats a known issue in php and there have been some tries to change this with patches (search the php.internals-list for those tries) but no patch has made it into the core.
most upload-progress meters therefore are using perl to save the file which saves it while uploading.
|

05-08-2006, 02:28 PM
|
|
New Member
|
|
Join Date: May 2006
Posts: 9
|
|
Yes , but the problem is once the upload is finished, it is NOT saving the file there, the only way to have it save the file is to use move_uploaded_file, then the file you move to will appear. The "file" you are copying from (tmp_name) does not exist on the servers HDD, so it must be storing it in RAM for some reason.
Quote:
|
Originally Posted by ts77
its only saving the file there once the upload is finished.
thats a known issue in php and there have been some tries to change this with patches (search the php.internals-list for those tries) but no patch has made it into the core.
most upload-progress meters therefore are using perl to save the file which saves it while uploading.
|
|

05-08-2006, 02:29 PM
|
|
Senior Member
|
|
Join Date: Nov 2004
Posts: 288
|
|
|
heh no, it *is* created. I did it many times and if you didn't move it, it appears there.
are you sure that you have the right permissions to *see* it?
|

05-08-2006, 02:31 PM
|
|
LiteSpeed Staff
|
|
Join Date: Oct 2003
Location: Los Angeles, California
Posts: 380
|
|
With regards to reading a pending upload (upload progress) check this thread:
http://www.litespeedtech.com/communi...pload+progress
As far as the tmp_file not created period on filesystem, I will attempt to duplicate this problem via PHP 5.1.4 + LSAPI and let you guys know my findings.
And btw...BB, if you can share a code snippet of your upload script which confirms that the tmp_file is not being created, that would help also. So we can pinpoint the problem.
Last edited by xing; 05-08-2006 at 02:33 PM..
|

05-08-2006, 02:35 PM
|
|
New Member
|
|
Join Date: May 2006
Posts: 9
|
|
Quote:
|
Originally Posted by ts77
heh no, it *is* created. I did it many times and if you didn't move it, it appears there.
are you sure that you have the right permissions to *see* it?
|
Hate to break your bubble, but *no* it is not created am I am logged in as root and a ls -a shows it not being there AT ALL if I do not use move_uploaded_file, if I use move_uploaded_file, the moved file "test1.move" appears almost instantly, but the tmp file is still not there and never was unless my filesystem is playing tricks on me.
For the record I am using PHP 5.1.4 w/ LSAPI 2.0
|

05-08-2006, 02:38 PM
|
|
New Member
|
|
Join Date: May 2006
Posts: 9
|
|
Quote:
|
Originally Posted by xing
|
Ok.. I noticed i tried it with a php patch but evidently lsws isn't forwarding the request to the multipart post_handler in rfc8167.c until the ENTIRE upload is completed... Is this correct?
If this is the case, it *may* be created the tmp_file but not being visible long enough before the script ends to show up (cause on end of script execution php will remove the tmp_file immediately).. If this is what is going on, there would be no way to check the progress of uploads unless you add support to handle "multipart/form-data" differently. Correct me if I am wrong.
Last edited by BuhBompus; 05-08-2006 at 02:45 PM..
|

05-08-2006, 02:52 PM
|
|
LiteSpeed Staff
|
|
Join Date: Oct 2003
Location: Los Angeles, California
Posts: 380
|
|
|
Correct, lsws will only forward request to backend after receiving the entire request, including body. Upload progress indicators/patches doest not current work with litespeed due to this feature.
There is a "receive" memory buffer setting in which Lsws uses for all requests. Lsws will use on disk buffer if the entire upload cannot be fit into the in memory receive buffer.
So a tip to improve uploads speeds and site with large post operations, is to increase the "receive" buffer.
Last edited by xing; 05-08-2006 at 02:55 PM..
|

05-08-2006, 05:04 PM
|
|
LiteSpeed Staff
|
|
Join Date: Oct 2003
Location: Los Angeles, California
Posts: 380
|
|
The temp files are being created. They are just created/destroyed very fast.
When into one of our beta tester's live file-upload server and did a simple repeat cli of:
Code:
cd /tmp/uploads/
ls php*
It took quite a few tries to finally reveal:
Figure this test method was quicker than coding up a script.
Setup:
PHP 5.1.4 + PHP LSAPI 2.0 + LSWS 2.1.15.
If you do a file read on the tmp_file before the move command, it should work.
|

05-08-2006, 05:28 PM
|
|
New Member
|
|
Join Date: May 2006
Posts: 9
|
|
Quote:
|
Originally Posted by xing
The temp files are being created. They are just created/destroyed very fast.
If you do a file read on the tmp_file before the move command, it should work.
|
You are correct. I guess I will have to live with using ajax/js to disable the upload button and display something that shows that it is working on the upload progress and then display a message once it is done.
Thanks for the quick replies!
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:29 AM.
|
|