简体   繁体   中英

Drag and drop upload image file size limit

I used to use a web hosting with cPanel and there is no problem with drag and drop image uploading ( every file is less than 2MB ).

The uploading method is like

<img src="data:image/jpeg;base64,xxxxxxx...">

and I post it on url into php to encode to a image file.

After I moved my website to another web hosting and some problem just happened with drag and drop uploading.

If any file size is larger than 730KB, the uploading will be fail.

I have google a lot, including modify php.ini like post_max_size , upload_max_filesize , even set ini_set('memory_limit', '256M') and ini_set('post_max_size', '8M') in php file, it's not working at all.

If your new hosting is not administrated by you, then they may have restricted the ability to set ini configs from the PHP scripts, and lowered the limit file uploads.

Also memory_limit is not the directive you need, is max_upload_size and post_max_size. memory_limit limits the amount of RAM that PHP can consume before fatal erroring.

I have found where the problem is.

based on my uploading method is drag and drop image, i tried to count post length with using "alert(encode.length)" and i found that if length of every file is longer than 1,000,000, it will shows error.

so i tried to find the value 1,000,000 in phpinfo()

it's

suhosin.post.max_value_length

so in

/etc/php5/conf.d/suhosin.ini

i change it 1,000,000 to 10,000,000 and remove the mark then restart apache, it works fine now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM