Tools, FAQ, Tutorials:
Detecting File Uploading Errors in PHP
How To Detect File Uploading Errors in PHP?
✍: FYIcenter.com
If there was a problem for a file upload request specified by the <INPUT TYPE=FILE NAME=fieldName...> tag, an error code will be available in $_FILES[$fieldName]['error']. Possible error code values are:
Based on the error codes, you can have a better logic to process uploaded files more accurately, as shown in the following script:
<?php
$file = '\fyicenter\images\fyicenter.logo';
$error = $_FILES['fyicenter_logo']['error'];
$tmp_name = $_FILES['fyicenter_logo']['tmp_name'];
print("<pre>\n");
if ($error==UPLOAD_ERR_OK) {
move_uploaded_file($tmp_name, $file);
print("File uploaded.\n");
} else if ($error==UPLOAD_ERR_NO_FILE) {
print("No files specified.\n");
} else {
print("Upload faield.\n");
}
print("</pre>\n");
?>
If you try this script with logo_upload.php and do not specify any files, you will get the "No files specified." message.
⇒ Filtering Out Empty Files in PHP
⇐ Moving Uploaded Files to Permanent Directory in PHP
2016-10-14, ∼1968🔥, 0💬
Popular Posts:
How to pull NVIDIA CUDA Docker Image with the "docker image pull nvidia/cuda" command? If you are ru...
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
How to convert JSON Objects to PHP Associative Arrays using the json_decode() function? Actually, JS...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
Where to find tutorials on EPUB file format? I want to know how to create EPUB books. Here is a larg...