Khao8
07-01-2009, 01:11 PM
Hey all,
I've been trying to allow my PHP to handle large file uploads and I can't seem to make it work. The thing is I want the larger limit to be only on one file (admin.php) because for other uploads made by normal users the default size limit is ok.
I've added php_value directives to my apache configuration inside a <LocationMatch> tag and it didn't work, so I added those lines to my admin.php :
@ini_set( 'upload_max_size' , '15M' );
@ini_set( 'post_max_size', '16M');
@ini_set( 'max_execution_time', '300' );
It still doesn't work. I don't receive any error message so it's really hard to figure out what's wrong with what I am doing. Uploading files under 2MB works fine and over that, it won't work. I'm on a dedicated server too so I should be able to override those settings easily.. Anybody can help me? Thanks
serversignature
07-01-2009, 01:58 PM
Change the setting using php.ini file.
All the configuration settings for your php installation are contained in the php.ini file.
You can call the phpinfo() function to find the location of your php.ini file, it will also tell you the current values.
jstanden
07-01-2009, 02:11 PM
If you prefix ini_set() with '@' then you'll suppress any errors and not see them anyway.
If your PHP is running with safe_mode=On then you won't be able to overload the php.ini using ini_set().
As mentioned above, your best bet is to increase the values in the php.ini file and then restart Apache.
Hey all,
I've been trying to allow my PHP to handle large file uploads and I can't seem to make it work. The thing is I want the larger limit to be only on one file (admin.php) because for other uploads made by normal users the default size limit is ok.
I've added php_value directives to my apache configuration inside a <LocationMatch> tag and it didn't work, so I added those lines to my admin.php :
@ini_set( 'upload_max_size' , '15M' );
@ini_set( 'post_max_size', '16M');
@ini_set( 'max_execution_time', '300' );
It still doesn't work. I don't receive any error message so it's really hard to figure out what's wrong with what I am doing. Uploading files under 2MB works fine and over that, it won't work. I'm on a dedicated server too so I should be able to override those settings easily.. Anybody can help me? Thanks
You might not be able to override those settings directly at runtime. The best bet is to modify those settings in your php.ini (and don't forget to restart your web server!)
01globalnet
07-01-2009, 07:59 PM
The 2 first settings must be changed server wide or per directory from your host - you cannot override these settings in your account with an .htaccess, php.ini or ini_set.
JBapt
07-03-2009, 09:46 AM
for large file uploads use the ftp class in php. Otherwise it will never work properly.
ramnet
07-03-2009, 07:52 PM
Hey all,<<snip>>
@ini_set( 'upload_max_size' , '15M' );
@ini_set( 'post_max_size', '16M');
@ini_set( 'max_execution_time', '300' );
I don't receive any error message <<snip>>
You won't get any errors with @ prepended since having @ prepended is like setting error_reporting(0); for that function call.
Remove the @ from the function call and the errors should appear.
xphoid
07-04-2009, 05:46 AM
The 2 first settings must be changed server wide or per directory from your host - you cannot override these settings in your account with an .htaccess, php.ini or ini_set.
You can override upload_max_size and post_max_size via htaccess.
The reason why it probably isn't working is because the file upload happens before the script is called. Set it outside the script (htaccess or php.ini), and it should work fine.