PHP uploading files php.ini configuration

Go To StackoverFlow.com

0

I have a question - I have a file uploader and each user is allowed to upload max_size:30M. Now I'd like to know from your experiences what I should set up in php.ini.

Here are the options I've already changed, but I'm not sure if that is the best:

upload_max_filesize = 30M

post_max_size = 30M 

max_execution_time = 300

max_input_time = 300

memory_limit = 32M

Here I think memory_limit is a bit low. And is there something more I have to include? When I tried to upload more than 30M, Firefox crashed.

Thanks for your answers.

2012-04-04 18:14
by Angel M.
What has firefox to do with your PHP setup? Both run on a totally different computer - hakre 2012-04-04 18:16
The memory limit must always be slightly larger than the uploadmax/postmax sizes - space for any posted/uploaded data/files, plus space for the script's own internal data - Marc B 2012-04-04 18:17
@hakre I know the browser has nothing to do with php.ini .. this is another problem to deal wit - Angel M. 2012-04-04 18:26
@Marc B I was thinking to allocate more memory but not sure - how much. At the same time I saw suggesting like to set memory_limit=-1, but I'm not sure about that, meaning about the safety of this - Angel M. 2012-04-04 18:27
if you're worried about a runaway script sucking up all memory, then don't -1 the limit. otherwise, you'll just have to chance that at some point some script is going to exceed the limit. If need be, you can use a <file> directive in apache to set a memorylimit override for just that one file with a phpvalue directive directly - keep all scripts locked down to (say) 10 meg, but for your upload script, raise the limit to (say) 40meg - Marc B 2012-04-04 18:40


0

If you work heavily with files you should split the file and upload it in separate parts, it doesn't choke the server as much and you can check the progress, also you don't need that much memory and excecution time.

For some reason someone said it's not true... Well I don't think Youtube or upload sites like Megaupload (rip) use 2gb of memory and 2 hours of maximum excecution time to upload the file of one user, they split the file, in whatever way they can, if you need to upload 30mb files, and you use standard PHP your webserver will choke until the upload finishes, unless you don't care about that, it's not recommended. The easiest solution is to upload it by parts, you can do it using Flash/Silverlight/JS/HTML5 or whatever way you prefer, client-side, and then joining them server-side.

2012-04-04 18:15
by gosukiwi
hm .. I wouldn't know how should be done this - for example if I upload 20M movie ... This is an ajax uploader - so it can upload multiple files or one by one - do you mean that would be better to upload files one by one ... - Angel M. 2012-04-04 18:25
Well how do you think Youtube lets you upload 2gb files? They split the file in smaller chunks and upload the chunks one by one, then, serverside, they join them, they don't use 2gb of ram memory, nor 2 hours maximum script excecution time.

To be able to do that, you will need to somehow split the file client-side, this is normally done with flash/silverlight/javascript/html - gosukiwi 2012-04-04 18:31

Ads