简体   繁体   中英

Possible to prevent server from timing out when uploading bulk images?

We have a site on Wordpress and use Woocommerce for our commerce site. In short we have a front end form that logged in users can upload multiple images at once. Problem is these images are typically straight off a digital camera and we need to keep them at the highest resolution possible.

When users try uploading even 50+ images it takes FOREVER and sometimes doesn't even complete, it will return a 504 error.

We talked to the host and have done all we can with them to decrease server timeouts and they suggested making edits to the attached script. I also went in to the wp_config file and set the max upload size to something like 256M.

This problem is still happening and I was just wondering if anyone had any recommendations on how to prevent server timeouts or speed up image uploads without totally reworking the code?

The attached code is here: http://pastebin.com/AHTDNaDL

Just to save some time while browsing that file lines 3 -175 handle the product creation for each image uploaded; line 253 - 340 is the upload form and line 447 starts the binding functions.

I have been at this for days and googled everything from plugins to ajax uploaders but still not having much luck, thinking some outside input would help

Edit: Since it doesn't look like I will be able to configure my server to what I need, is it possible to break the upload/creating of product up into a few different sections? In other words, the user would be able to upload all there images and then in the background I could run my create_var_product function to hopefully prevent timeout issues?

You need to edit your php.ini file. Look at editing at least the following:

max_input_time
upload_max_filesize

Check the documentation:

http://us3.php.net/ini.core

Try adding the following lines to the top of the script:

ini_set('max_execution_time', 10000);
set_time_limit(0);
ini_set('memory_limit', '-1');

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