There is a stff that requires temporary file upload for transit, so he wrote an uploadsphp file to facilitate his upload and download. Save the following code as uploadsphp and place it in the www Directory. & lt ;! DOCTYPEhtmlPUBLIC & quot;-W3CDTDXHTML10TransitionalEN & quot; when there is a stff, you need to upload files temporarily for transit, so you have written an uploads. php file to facilitate upload and download. Save the following code as uploads. php and put it in the www directory.
Simple file Upload
$ K) {$ d_root_no = strlen ($ d_root); $ l = substr ($ k, $ d_root_no); echo $ v. 'File :'. $ _ SERVER ['server _ ADDR ']. $ l.'
';} $ Upload_file = isset ($ _ FILES ['upload _ file'] ['tmp _ name'])? $ _ FILES ['upload _ file'] ['tmp _ name']: ''; $ upload_file_name = isset ($ _ FILES ['upload _ file'] ['name'])? $ _ FILES ['upload _ file'] ['name']: ''; $ upload_file_size = isset ($ _ FILES ['upload _ file'] ['size'])? $ _ FILES ['upload _ file'] ['size']: ''; if ($ upload_file) {$ file_size_max = 1000*1000*200; // MB limit the maximum file upload capacity (bytes) if (! Is_dir ($ store_dir) {mkdir ($ store_dir, 0777, true);} $ accept_overwrite = 1; // whether to overwrite the same file // check the file size if ($ upload_file_size> $ file_size_max) {echo "Sorry, your file capacity exceeds the limit"; exit ;} // Check the read/write file if (file_exists ($ store_dir. $ upload_file_name )&&! $ Accept_overwrite) {echo "files with the same file name exist"; exit;} // copy the file to the specified directory if (! Move_uploaded_file ($ upload_file, $ store_dir. $ upload_file_name) {echo "file copy failed"; exit ;}} if (isset ($ _ FILES ['upload _ file']) {echo"You uploaded the file: "; echo isset ($ _ FILES ['upload _ file'] ['name'])? $ _ FILES ['upload _ file'] ['name']: ''; echo"
"; // The original name of the client machine file. Echo "the MIME type of the file is:"; echo isset ($ _ FILES ['upload _ file'] ['type'])? $ _ FILES ['upload _ file'] ['type']: ''; // MIME type of the file, which must be supported by the browser, for example, "image/gif ". Echo"
"; Echo" upload file size: "; echo isset ($ _ FILES ['upload _ file'] ['size'])? $ _ FILES ['upload _ file'] ['size']: ''; // size of the uploaded file, in bytes. Echo"
"; Echo" is temporarily stored after the file is uploaded: "; echo isset ($ _ FILES ['upload _ file'] ['tmp _ name'])? $ _ FILES ['upload _ file'] ['tmp _ name']: ''; // temporary file name stored on the server after the file is uploaded. $ Erroe = isset ($ _ FILES ['upload _ file'] ['error'])? $ _ FILES ['upload _ file'] ['error']: ''; switch ($ erroe) {case 0: echo" uploaded successfully "; break; case 1: echo "the uploaded file exceeds php. the value of the upload_max_filesize option in ini. "; break; case 2: echo" the size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form. "; Break; case 3: echo" only part of the file is uploaded "; break; case 4: echo" no file is uploaded "; break; case 6: echo "no cache directory"; break; case 7: echo "Upload directory unreadable"; break; case 8: echo "Upload stopped"; break; default: echo "file uploading not selected"; break;} echo"