PHP uploading files from a form - how to resolve issues (legacy version only)
IMPORTANT: this is for legacy version of API and on-prem version with file uploading from forms.
If you experience issues uploading file from HTML form then please try to resolve using the following step:
Try to use
urlencode()for filenames that may contain spaces. Example:
Check HTML form to make sure it uses
POSTmethod but not
php.ini. On some configurations, it may have been set to the zero so no uploads are allowed at all.
php.ini. PHP may return
500error if input file is larger than this option, i.e. if uploaded file is larger than max allowed file size.
php.ini. PHP uses this constant to set limits for the the total size of that comes from submitted form (including non-file fields too). If total submitted data size is larger than this constant, you will get
php.iniwhich defines temp folder. This folder is used to temporary store data. Sometime this folder is not writable. To resolve the issue, make sure that temp folder is writable from PHP.
Finally, enable PHP errors using the following code snippet in your PHP script:
error_reporting(E_ALL); ini_set("display_errors", 1);
Reference: Fix: PHP upload form not working. by Double You Media, Wexford, Ireland. Retrieved on April 22, 2022.