Resolving Attachments Upload Issues

PHP.ini Settings

There are important settings on the server size in the PHP.ini controlling the upload process. Make sure to configure them correctly, or ask your hosting support to do it for you (if you don’t have access to the PHP.ini).

If you are not sure about any of these, make sure to talk to your hosting support about properly configuring upload
limits based on what you need.

  • file_uploads this has to be set to on.
  • upload_tmp_dir this points to the temporary directory to store uploaded files before processing.
  • upload_max_filesize this is the maximum size of a single file allowed to upload.
  • max_file_uploads this limits number of files that can be uploaded at once.
  • post_max_size total size of the POST request allowed. This includes all the files uploaded in the single request.

Some hosting companies can have limits on any of these values, and will not allow files beyond certain size to be
processed by PHP. Make sure to check with your hosting company about these limits.

Temporary directory access

By default, upload_tmp_dir can be empty or not used at all, and the server temp directory will be used. Make sure that PHP has access to temporary directory, or uploads will not work at all. On most hosting setups, you can’t control the temp directory, and this option will be set on server level beyond your control.

Upload size limitations

Each file upload is done as a part of POST request type. POST request has own max allowed size limit, and that limit includes all the POST fields, including files. If you want to allow users to upload maximum of 8 files, and each file can be 64MB in size, than POST max size has to be at least 512MB.

File MIME Type

For each file uploaded, WordPress will run series of checks, and one of them will be checking if the upload file MIME type is allowed. This is not just checking extension for the file, but, using PHP function it will get the MIME type from the uploaded file, and check if the extension and MIME type are a match. If you try to upload file with the extension that is not included valid MIME Type, the file will be rejected.

WordPress has a long list of allowed MIME types and extensions. But, as with many things in WordPress, you can register additional extensions and MIME types. With GD bbPress Toolbox Pro, you can use Extra MIME Types feature to add new extensions and MIME types.

But, if you add new extensions, and the MIME type you add for it doesn’t match the actual MIME type (the MIME type PHP will read), WordPress file check for that extension will fail, and file upload will not be allowed.

Make sure that any MIME Type and extension combination you want to add match!

An example

For instance, if you want to add .reg file type (for WordPress Registry entries), that file is a text file, and it should work with text/plain MIME Type. But, actually, the MIME type for it is text/x-ms-regedit. And, only if you set .reg with the text/x-ms-regedit MIME type, that file will be accepted by the PHP upload.

0
0
34
Rate this article

You are not allowed to rate this post.

Leave a Comment