How can I use php to upload a fixed simple file? 1. fixed a file to be uploaded to the server. the file name is fixed and does not need to be specified.
2. Upload and save the file in a specified folder. if there is a file with the same name, delete the original one.
How is the above functions the simplest?
Reply to discussion (solution)
/* Upload error
0 uploaded successfully
1. the file size exceeds the server space.
2. the size of the file to be uploaded exceeds the browser limit.
3. only part of the file is uploaded.
4. the file to be uploaded is not found.
5. the temporary folder on the server is lost.
6. An error occurred while writing the file to the temporary folder.
*/
$ File_type = array ('jpg ', 'PNG', 'GIF', 'Doc', 'txt '); // sets the upload category
$ File_name = 'myfile _ name'; // sets the file name after Upload.
$ File_dir = 'upimg '; // sets the upload directory.
If ($ _ POST ['submitpic ']) {
$ Files = $ _ FILES ['mypic '];
// Determine the error level
If ($ files ['erorr']! = 0 ){
Exit ('Upload error ');
}
// Determine whether the upload type meets the conditions
$ UpName = $ files ['name']; // Get the name of the uploaded file
$ Uptype = explode ('.', $ upName); // Convert it to an array
$ Uptype = end ($ uptype); // Obtain the file type
If (! In_array ($ uptype, $ file_type )){
Exit ('Type invalid ');
}
// Move the file to the specified folder
If (move_uploaded_file ($ files ['tmp _ name'], $ file_dir. '/'. $ file_name. '.'. $ uptype )){
Echo "Upload successful! ";
}
}
?>
The answer is No.
If the uploaded file is a linux password or Windows registry file, would you like it?
Move_uploaded_file
There is no problem with uploading. now, how does one omit the process of selecting files and submitting them.
Check the php file upload. there is no need to consider so many things.
The success rate of FTP uploading is not guaranteed.
The problem is really amazing!