LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > PHP > Uploading files / tmp file creation

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2006, 02:20 PM
BuhBompus BuhBompus is offline
New Member
 
Join Date: May 2006
Posts: 9
Default 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?
Reply With Quote
  #2  
Old 05-08-2006, 02:26 PM
ts77 ts77 is offline
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.
Reply With Quote
  #3  
Old 05-08-2006, 02:28 PM
BuhBompus BuhBompus is offline
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.
Reply With Quote
  #4  
Old 05-08-2006, 02:29 PM
ts77 ts77 is offline
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?
Reply With Quote
  #5  
Old 05-08-2006, 02:31 PM
xing xing is offline
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..
Reply With Quote
  #6  
Old 05-08-2006, 02:35 PM
BuhBompus BuhBompus is offline
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
Reply With Quote
  #7  
Old 05-08-2006, 02:38 PM
BuhBompus BuhBompus is offline
New Member
 
Join Date: May 2006
Posts: 9
Quote:
Originally Posted by xing
With regards to reading a pending upload (upload progress) check this thread:

http://www.litespeedtech.com/communi...pload+progress
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..
Reply With Quote
  #8  
Old 05-08-2006, 02:52 PM
xing xing is offline
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..
Reply With Quote
  #9  
Old 05-08-2006, 05:04 PM
xing xing is offline
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:

Code:
php5H2YTt
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.
Reply With Quote
  #10  
Old 05-08-2006, 05:28 PM
BuhBompus BuhBompus is offline
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!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
lsz files jrmarino General 1 07-24-2007 11:00 AM
Restrictions on uploading files via POST in LS subBlue Install/Configuration 2 01-19-2007 09:40 AM
Problem installing LiteSpeed 2.2.1 Standard on UNIX perezsy Install/Configuration 17 09-22-2006 09:53 AM
Request: Uploading text files for ip block lists MagicMike Feedback/Feature Requests 1 03-11-2005 09:30 AM
Uploading Files Channel_Cat Bug Reports 6 10-21-2004 12:29 AM


All times are GMT -7. The time now is 06:29 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.