Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Detect File Uploading Errors
How To Detect File Uploading Errors? - PHP Script Tips - Uploading Files to Web Servers
✍: 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.
2007-04-19, 5324👍, 0💬
Popular Posts:
How To Run a JUnit Test Class? A JUnit test class usually contains a number of test methods. You can...
What is shadowing ? When two elements in a program have same name, one of them can hide and shadow t...
What invokes a thread's run() method? After a thread is started, via its start() method of the Threa...
How To Set Background to Transparent or Non-transparent? - CSS Tutorials - HTML Formatting Model: Bl...
Rachel opened her math book and found that the sum of the facing pages was 245. What pages did she o...