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:urlencode($_FILES["files"]["name"][$i])Check HTML form to make sure it uses
POSTmethod but notGETSearch for
file_uploadsconstant inphp.ini. On some configurations, it may have been set to the zero so no uploads are allowed at all.Check
upload_max_filesizeinphp.ini. PHP may return500error if input file is larger than this option, i.e. if uploaded file is larger than max allowed file size.Check
post_max_sizeconstant inphp.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 get500error.Check
upload_tmp_dirinphp.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.