Loading...
Changes Saved.
Error Occurred!

KnowledgeBase

Trouble uploading files

If you are encountering file uploading trouble, first try uploading a small text file. If that does not work, ensure that (file_uploads) is turned on in your php.ini and you have no file upload limitations on your server.

If you can only upload small files and are unable to upload any larger files (such as any file greater than 1 mb, you should look into the following)

  • PHP Settings
    • allow_url_fopen - should be on
    • file_uploads - should be on
    • upload_max_file_size - should be larger than the files you are trying to upload
    • post_max_size - should be larger than the files you are trying to upload
      • Files are usually POSTed to the webserver in a format known as 'multipart/form-data'. The post_max_size sets the upper limit on the amount of data that a script can accept in this manner. Ideally this value should be larger than the value that you set for upload_max_filesize.
      • It's important to realize that upload_max_filesize is the sum of the sizes of all the files that you are uploading. post_max_size is the upload_max_filesize plus the sum of the lengths of all the other fields in the form plus any mime headers that the encoder might include. Since these fields are typically small you can often approximate the upload max size to the post max size.
    • memory_limit
      • When the PHP engine is handling an incoming POST it needs to keep some of the incoming data in memory. This directive has any effect only if you have used the --enable-memory-limit option at configuration time. Setting too high a value can be very dangerous because if several uploads are being handled concurrently all available memory will be used up and other unrelated scripts that consume a lot of memory might effect the whole server as well.
    • upload_tmp_dir - Should be a valid directory. If using IIS this directory should have correct permissions for the server to write to.
    • max_execution_time - Increase to a larger number such as 250 or 500
      • Also, max_input_time. These settings define the maximum life time of the script and the time that the script should spend in accepting input. If several mega bytes of data are being transfered max_input_time should be reasonably high. You can override the setting in the ini file for max_input_time by calling the set_time_limit() function in your scripts.
  • MySql Settings - If you are still having problems uploading files greater than 1mb after changing the php settings you may have to adjust a MySql setting as all the files are technically stored in the database.
    • max_allowed_packet - This may default to 1 mb. Adjust this to 16 mb. http://www.mysql.com/news-and-event...0000000216.html
    • Your mysql configuration file will likely be a “my.cnf” file. Typically you can find this at /etc/my.cnf on non-windows servers.
      • If you are using MySQL 4.0 or newer, enter:
 [mysqld]
# Allow packets up to 16M
 max_allowed_packet=16M
  • If you are using an older version of MySQL, enter:
[mysqld]
# Allow packets up to 16M
set-variable = max_allowed_packet=16M
  • Other Settings
    • Beyond PHP & MySQL you may also have file size restrictions in Apache (httpd.conf) or IIS.
    • Apache info http://httpd.apache.org/docs/mod/co...imitrequestbody

These settings are all at the server level, and if you do not have access to the appropriate files and settings you will need to contact your system administrator to see if they will enable higher limits and other server adjustments. If problems continue and you or your server admin are unable to resolve the issue, you may need to contact the server software manufacturer for additional support.



Related Articles