PDA

View Full Version : Upload weirdness.


tortenazor
04-05-2007, 08:30 AM
HI,

I know this must have been answered hundreds of times, but after searching the forums and following all steps, I'm still stuck on this.

I have this file uploading scripts which execute in php4. Bigger uploads were failing, so I followed the tutorials and added this to my .htaccess

php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value output_buffering on
php_value max_execution_time 1000
php_value max_input_time 1000

RewriteEngine On

# Turn off mod_security filtering.
SecFilterEngine Off

# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off

Now for uploads bigger that about 2M I get this:

Warning: move_uploaded_file(/tmp/phpZk1W3w) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/bailscom/public_html/video_upload_test.php on line 55

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpZk1W3w' to 'tempvideos/321321321_3232.mov' in /home/bailscom/public_html/video_upload_test.php on line 55

I've been doing some googling and found this post in some forum.

"I spent a good 2 hours today wondering why I could not upload files larger than 15MB even after upping my post_max_size, max_execution_time, max_input_time, and upload_max_filesize. Turns out php stores the uploaded file in memory until you do something with it. SO you also NEED to set the memory_limit to the correct file size."

So I told to myself, lets add this to my htaccess. But nothing changed and phpinfo() did not print any memory_limit variable.

Then I thought maybe I should move to php5. I did, and now it seems than the upload_max_filesize defaults to 2M no matter what I put into .htaccess and php.ini

Now I'm stuck. I have this feeling this is working for everybody but me and I'm missing something very obvious.

I've put up a small test page here:

http://cozy.cirtexhosting.com/~bailscom/test.html


And I'm pasting what's inside my .htaccess and php.ini here:


php.ini

memory_limit 100M
upload_max_filesize 100M
post_max_size 100M
output_buffering on
max_execution_time 1000
max_input_time 1000

RewriteEngine On

# Turn off mod_security filtering.
SecFilterEngine Off

# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off

.htaccess

php_value memory_limit 100M
php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value output_buffering on
php_value max_execution_time 1000
php_value max_input_time 1000

RewriteEngine On

# Turn off mod_security filtering.
SecFilterEngine Off

# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off


I'm lost here... I'd appreciate any help.

Cirtex Joshua
04-05-2007, 10:50 AM
I'll have to change memory limit on our end, check it in about 20-30 minutes.

tortenazor
04-05-2007, 12:04 PM
Hi,

I tried again with a 5M file and got this.

Warning: move_uploaded_file(/tmp/phpUYxJ15) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/bailscom/public_html/video_upload_test.php on line 55

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpUYxJ15' to 'tempvideos/321321321_3232.mov' in /home/bailscom/public_html/video_upload_test.php on line 55


Should I be using php4 or php5 ?

Cirtex Joshua
04-05-2007, 12:12 PM
Reading this again, note:

/tmp/phpUYxJ15 : no such file

so then of course it will fail to move since it doesnt exist

Send a ticket in to support@cirtexhosting.com so we can test and fix.

tortenazor
04-05-2007, 12:26 PM
HI,

I submited a ticket ( VGH-205403 ). I'm guessing it is a memory issue, as files below 2M do get created, but I'm not a backend guy so I may be wrong.

Let me know. If there's something I must change In my coding I will.

Cirtex Joshua
04-05-2007, 01:05 PM
I see the ticket.

chris
05-03-2007, 09:21 AM
I cannot get my usual file upload script to work at all, even for smallish files. I would be very grateful to anyone who could tell me what php code they are using. Using a standard form:

<form enctype='multipart/form-data' action='upload_video_process.php' method='post'>

<table border=1>
<tr><td>Upload video</td><td><input name='userfile' type='file' size='60'></td></tr>
<tr><td colspan=2 align=right><input type='submit' value='Upload'></td></tr>
</table>
</form>

and a script at the other end:

if ($userfile=="none")
{
echo "Problem: no file uploaded";
exit;
}
if ($userfile_size==0)
{
echo "Problem: uploaded file is zero length";
exit;
}

$current_dir = getcwd();
$userfile = $HTTP_POST_VARS["userfile"];
//$userfile_name = $HTTP_POST_VARS["userfile_name"];
$upfile = $current_dir."/".$userfile_name;
echo "$upfile<br />";
if(move_uploaded_file($userfile,$upfile)){
echo"file uploaded";
}
else{
echo"File could not be uploaded to $upfile";
}

I am getting "Problem: uploaded file is zero length"

Any help much appreciated

Chris (West Wales in case you're interested)

guear
05-03-2007, 11:27 AM
Hmmm I am not expert in php but is $userfile_size even defined?

chris
05-03-2007, 12:17 PM
Because the input type is specified as 'file' PHP knows the value of userfile_name and userfile_size from the value of userfile, its an in-built function...in this case the script didn't seem to be picking up the value of $userfile (the usefile field value). Because i am used to working with registyer_globals on I tried the HTTP_POST_VARS syntax and that didn't work, but having taken half an hour out to see my wife and son i went back to my well thumbed PHP manual and the formulation I needed was:

$userfile = $HTTP_POST_FILES["userfile"]["tmp_name"];
$userfile_name = $HTTP_POST_FILES["userfile"]["name"];
$userfile_size = $HTTP_POST_FILES["userfile"]["size"];
$userfile_type = $HTTP_POST_FILES["userfile"]["type"];

Now its working, so thanks for your comment which prompted me to think again! I blame lack of sleep myself (that's my son's department!)

Cheers,

Chris

chris
05-04-2007, 09:56 AM
I'll have to change memory limit on our end, check it in about 20-30 minutes.

I'm have a similar problem with uploading larger files and converting them, any chance my memory limit can be increased!?