homepage Welcome to WebmasterWorld Guest from 54.204.58.87
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Alter and revert ini upload settings
neophyte




msg:4541912
 4:13 am on Feb 3, 2013 (gmt 0)

Hello All -

I'm writing a script to upload a bunch of images. The number of images to be uploaded can be defined by the user. I've discovered that, if the total number of images (or total size of all images to be uploaded) exceeds the php ini setting, than the .ini settings must be edited to match or exceed the total number and/or total size of images uploaded.

What I'd like to do is, for example:

$maxSiz = ini_get('upload_max_filesize'); then...

Calculate the KB of all images to be uploaded.

If the total KB of all images to be uploaded exceeds upload_max_filesize, then I'd...

ini_set('upload_max_filesize', $newFilesizeValue); then...

Upload the files, then...

reset .ini to the original values.

So, after all of that the core questions is:

1. can these ini settings be altered on the fly?
2. would apache need to be restarted for the changes to take effect?
3. If these specific ini settings CANNOT be changed on the fly or if apache WOULD need to be restarted, then is there a maximum upload value I should use?

Thanks to all in advance!

 

rainborick




msg:4544567
 4:11 pm on Feb 11, 2013 (gmt 0)

I don't know the specific answer about whether 'upload_max_filesize' can be set within a script, but it seems to me that developers need to realize that uploading via PHP (or any language) has several limitations and 'upload_max_filesize' is only one of them. For example, you also have to deal with the maximum script execution time. On shared hosts, you're unlikely to be able to override these settings.

And while users generally have pretty fast download speeds these days, upload speeds are almost always much slower. Even if you can work around the php_ini settings, one or two users trying to upload a handful of multi-megabyte image files can slow your server to a crawl.

If you really want to provide this capability, you'll probably need a fast dedicated server. Failing that, the best route might be a solution that relies on FTP rather than HTTP. There are some Java applets out there like JUPload that might help.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved