Use the SWFUpload plug-in to upload files and swfupload to upload files. Use the SWFUpload plug-in to upload files. the demo code of swfupload to upload files consists of two parts: front-end files and background files: 1.front-end file index.html! DOCTYPEhtmlPUBLIC-use the SWFUpload plug-in to upload files and swfupload to upload files
The demo code consists of two parts, including foreground and background files:
1.front file index.html
SWFUpload
SWFUpload
V2.2.0
Click "browse" and select the document file to be uploaded. The system will automatically upload the file and prompt you after it is complete.
Do not upload files containing Chinese file names!
Quick Upload
0 files uploaded
Hanization By Leo. C,
2. background file upload. php
$ Multiplier * (int) $ POST_MAX_SIZE & $ POST_MAX_SIZE) {header ("HTTP/1.1 500 Internal Server Error"); echo "POST exceeded maximum allowed size. "; exit (0);} // basic settings $ save_path = getcwd (). "/file/"; // file upload location $ upload_name = "Filedata"; $ max_file_size_in_bytes = 2147483647; // 2 GB $ extension_whitelist = array ("doc", "txt ", "jpg", "gif", "png"); // allows the file type $ valid_chars_regex = '. a-Z0-9 _! @ # $ % ^ & () + ={}\ [\] \ ', ~ '-'; // File name rules // Other variables $ MAX_FILENAME_LENGTH = 260; $ file_name = ""; $ file_extension = ""; $ uploadErrors = array (0 => "file uploaded successfully", 1 => "the uploaded file exceeds php. the setting in upload_max_filesize directive in the ini file ", 2 =>" the uploaded file exceeds the setting in MAX_FILE_SIZE directive in the HTML form File ", 3 => "only part of the uploaded file", 4 => "No file upload", 6 => "temporary folder missing "); // check whether the file is uploaded correctly if (! Isset ($ _ FILES [$ upload_name]) {HandleError ("No upload found in \ $ _ FILES ". $ upload_name); exit (0);} else if (isset ($ _ FILES [$ upload_name] ["error"]) & $ _ FILES [$ upload_name] ["error"]! = 0) {HandleError ($ uploadErrors [$ _ FILES [$ upload_name] ["error"]); exit (0);} else if (! Isset ($ _ FILES [$ upload_name] ["tmp_name"]) |! @ Is_uploaded_file ($ _ FILES [$ upload_name] ["tmp_name"]) {HandleError ("Upload failed is_uploaded_file test."); exit (0);} else if (! Isset ($ _ FILES [$ upload_name] ['name']) {HandleError ("File has no name. "); exit (0);} // check the file size $ file_size = @ filesize ($ _ FILES [$ upload_name] [" tmp_name "]); if (! $ File_size | $ file_size> $ max_file_size_in_bytes) {HandleError ("File exceeds the maximum allowed size"); exit (0);} if ($ file_size <= 0) {HandleError ("File size outside allowed lower bound"); exit (0);} // The detection File name is blank $ file_name = preg_replace ('/[^ '. $ valid_chars_regex. '] | \. + $/I ', "", basename ($ _ FILES [$ upload_name] ['name']); if (strlen ($ file_name) = 0 | strlen ($ file_name)> $ MAX_FILENAME_LENGTH) {HandleError ("Invalid file name"); exit (0) ;}// check if (file_exists ($ save_path. $ file_name) {HandleError ("File with this name already exists"); exit (0 );} // Check the suffix $ path_info = pathinfo ($ _ FILES [$ upload_name] ['name']); $ file_extension = $ path_info ["extension"]; $ is_valid_extension = false; foreach ($ extension_whitelist as $ extension) {if (strcasecmp ($ file_extension, $ extension) = 0) {$ is_v Alid_extension = true; break ;}} if (! $ Is_valid_extension) {HandleError ("Invalid file extension"); exit (0) ;}// save the file if (! @ Move_uploaded_file ($ _ FILES [$ upload_name] ["tmp_name"], $ save_path. $ file_name) {HandleError ("the file cannot be saved. "); exit (0);} // echo" File already ed "is successfully output; exit (0 );
Function HandleError ($ message) {header ("HTTP/1.1 500 Internal Server Error"); echo $ message;}?>
The ghost demo code consists of two parts: front-end files and background files: 1. front-end file index.html! DOCTYPE html PUBLIC "-//...