On a multi-user site, I’ve gotten feedback that some users have been having trouble uploading their profile images on one form, and documents on another. However, I haven’t been able to get specific information on the errors received. Can you all come up with a checklist of things to test? I can’t find any errors.
This kind of thing is quite tricky to test.
What I generally do, when something that works for some people and not for others, is to email a var_dump($_FILES) whenever something is uploaded. That should contain the error code for the upload, which may give some more information. (alternatively, you could write the var_dump() to a text file and check it every now and then).
From there, you could try to find out why the upload is failing for some users.
Are you using a Flash uploader or a standard file input?
<?php
function file_upload_error_message($error_code) {
switch ($error_code) {
case UPLOAD_ERR_INI_SIZE:
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
case UPLOAD_ERR_FORM_SIZE:
return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
case UPLOAD_ERR_PARTIAL:
return 'The uploaded file was only partially uploaded';
case UPLOAD_ERR_NO_FILE:
return 'No file was uploaded';
case UPLOAD_ERR_NO_TMP_DIR:
return 'Missing a temporary folder';
case UPLOAD_ERR_CANT_WRITE:
return 'Failed to write file to disk';
case UPLOAD_ERR_EXTENSION:
return 'File upload stopped by extension';
default:
return 'Unknown upload error';
}
}
// Example
if ($_FILES['file']['error'] === UPLOAD_ERR_OK)
// upload ok
else
$error_message = file_upload_error_message($_FILES['file']['error']);
?>
Thank you, these comments are very helpful. Its a plain html uploader. They need javascript to work. That could be part of the issue. Javascript could be blocked on some computers.
SpacePhoenix I definitely have some of those validation catches but I’ll check to see if I have all of them. That’s a good list.