Page 1 of 1

Problem with uploading large files - over 2mg

Posted: Fri Jun 06, 2003 2:00 pm
by CAN007
I need to have files uploaded upto say 20Mg. I have put this small test script together to simplify, and to try and solve this problem.

The test files I have been using are 4-6Mg... all other files, >2Mg work fine.

Any suggestions?
----------------------------------------------
<?php ini_set('upload_max_filesize','20M'); ?>
<html>
<head>
<body>
<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="20000000">
File: <input name="userfile" type="file" /><br />
<input type="submit" value="Upload" />
</form>

<?php
if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
copy($_FILES["userfile"]["tmp_name"], "files/" . $_FILES["userfile"]["name"]);
echo "<p>File uploaded successfully.</p>";
}
?>
</body></html>
-----------------------------------
Thanks,
James

Posted: Fri Jun 06, 2003 2:48 pm
by twigletmac
You need to change the upload_max_filesize in the php.ini, ini_set() will have no effect on it because the file's already been passed to PHP before the ini setting is changed.

http://php.net/ini_set

Mac

php ini?

Posted: Fri Jun 06, 2003 3:05 pm
by CAN007
Is this to be set on the server? Im not quite following you here.

Where would I locate php.ini?

Posted: Fri Jun 06, 2003 3:54 pm
by Galahad
In Linux (and probably Unix systems too), it is "/etc/php.ini" on the server. I believe you also have to change an apache config variable that limits the max request size, though. I hope you run your own server.

Posted: Sat Jun 07, 2003 1:18 am
by CAN007
Just this afternoon I realized that you would assume that I did run my own server... however, I do not... I contacted the host today, and they seem reluctant to do this request, however, we shall see.

Will let you know. :)

James

Posted: Sat Jun 07, 2003 10:41 pm
by CAN007
Found you can alter the php.ini values in the .htaccess in the root directory... got it over 2Mg, but now Ive hit the hurdle of 8Mg.

ini_set('upload_max_filesize','50M');
ini_set('post_max_size','55M');
ini_set('max_execution_time','60');
ini_set('memory_limit','50M');

I have tried the above values in the .htaccess as well... but still not able to get over 8Mg.

Any ideas?

Thanks, James

Posted: Sun Jun 08, 2003 3:33 am
by Galahad
Like I said before, I believe that you have to change an apache configuration variable. Look on this page for a description of "LimitRequestBody". They even mention it limiting file upload size.

Posted: Sun Jun 08, 2003 11:10 pm
by CAN007
I dont blieve I can adjust the server, as I do not host the site.... wherein, the problem lies.

I have sent an email to the host to request this, however, I do not think they want to change a global setting...

I hope I am incorrect on both counts... or either one will do! :)