Reputation: 3289
I am working on multiple file upload functionality where I am getting error when I print the file array as:
print_r($_FILE);
Gets error as:
Array
(
[name] => _agiewniki_Forrest_in_Autumn.jpg
[type] =>
[tmp_name] =>
[error] => 1
[size] => 0
)
I don't see the error description, the error only this
[error] => 1
Upvotes: 0
Views: 2714
Reputation: 12689
You can use this array to display file-upload error messages:
$error_messages = array(
UPLOAD_ERR_OK => 'There is no error, the file uploaded with success',
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded',
UPLOAD_ERR_NO_FILE => 'No file was uploaded',
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder',
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk',
UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload',
);
// prints "The uploaded file exceeds the upload_max_filesize directive in php.ini"
echo $error_messages[$_FILES['error']];
Upvotes: 4
Reputation: 22711
Based on the $_FILES['userfile']['error']
value you can print the respective error message in the ref document.
Add all the error messages in some array with respective error key value. Based on the error key value received from the $_FILE
during upload, and show the respective error message[Link added below].
Error Messages Explained :
Error Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
For more & Ref: http://www.php.net/manual/en/features.file-upload.errors.php
Upvotes: 1
Reputation: 5260
Here you can find by the code of error the description
In your case it is: The uploaded file exceeds the upload_max_filesize directive in php.ini.
Upvotes: 1
Reputation: 20
http://www.php.net/manual/en/features.file-upload.errors.php
UPLOAD_ERR_INI_SIZE Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
Hope to help
Upvotes: 1