Reputation: 57176
Can we reduce an image file size with PHP if it exceed the the limit set by upload_max_filesize
?
For instance, the upload_max_filesize
at my serve is only 3MB, but the image file size for uploading is 4MB, so can I reduce 4MB to 3MB via some PHP function?
Or any other scripting programme can do this (I don't mean using Photoshop to reduce the file size)?
Upvotes: 0
Views: 2144
Reputation: 5092
If you can use .htaccess
file, put this:
php_value upload_max_filesize 4194288
php_value post_max_size 4194288
4194288 = 4MB
Upvotes: 0
Reputation: 449435
No - it's impossible for PHP to ever get hold of that file if it is too big.
You would have to use client-size resizing, which is possible using Flash- or Java-based uploaders:
Upvotes: 1
Reputation: 1468
arnaud is correct. However, if you are able to change the upload_max_filesize, you could increase it and then resize any file that exceeds the max desired size using gd.
Upvotes: 0
Reputation: 99921
No, you can't. If the file size exceeds upload_max_filesize
, PHP will just refuse the upload, so you have no opportunity to resize it.
Upvotes: 3