This article provides you with a simple php file upload function code. If you are a beginner of php, this file upload code is easy to understand and can be used as an example. This article provides you with a simple php file upload function code. If you are a beginner of php, this file upload code is easy to understand and can be used as an example.
Script ec (2); script
If ($ _ FILES ['file']) {
// Outputs //----------------------------------------------------------------------------------------------//
//
// Description: File Upload Date: 2004-5-2
//
// Outputs //----------------------------------------------------------------------------------------------//
// Upload settings
$ Maxsize = 10002400; // maximum file size that can be uploaded
$ Alltype = array (". php", ". php3"); // all file types that can be uploaded
$ Imgtype = array (". php", ". php3"); // type
// Determine the file size
If ($ _ FILES ['file'] ['SIZE']> $ maxsize ){
Echo "the information you uploaded exceeds 10000 kb ";
Exit;
}
// Determine the file type
$ Type = strstr ($ _ FILES ['file'] ['name'], ".");
If (in_array ($ type, $ alltype )){
Echo "this type of file cannot be uploaded ";
Exit;
}
Include './uploaddir. php ';
$ Time = date ("Ymd-His", time ());
$ Fn = $ time. $ type;
$ Destination = $ updir. "/". $ fn;
If (@ move_uploaded_file ($ _ FILES ['file'] ['tmp _ name'], $ destination )){
@ Chmod ($ destination, 0777 );
$ Fileurl = $ updir. "/". $ destination;
$ Fileurl = "". $ destination;
} Else {
Echo "Upload Failed! ";
Echo "script location. href = history. back () script";
}
// Outputs //----------------------------------------------------------------------------------------------//
}
If ($ back = "no "):
Echo "OK ";
Exit;
Endif;
?>
Upload files