Tips and Problem Solving

Website or WordPress file upload fails

The Problem

When attempting to upload a file in a web browser, via a PHP script, the upload fails.

Common Causes

  1. Incorrect permissions on the PHP script
    (i.e. the PHP script file is not allowed to write to the upload directory)
  2. The PHP configuration is limiting the size allowed
  3. The amount of time for the script to run
    (i.e. if a file will take 34 seconds to upload but PHP is only allowing 30 seconds, it will fail)

Solution

You must edit the php.ini file on the web server to adjust the limits. Specifically

upload_max_filesize =
post_max_size =
max_execution_time =

CAUTION: Do not increase these dramatically as it can present a security risk, make sure you limit to the file you’re uploading. If it’s a one-off upload, reduce the PHP parameters once uploaded.

Need help solving this problem? Get in touch and we’ll hop on a webex to help.