I wrote a classic file Upload class for you in the class, and the flexibility is also good. For more information, see upload files: & lt ;? Php/*** author: PHP100.com * date: 2012-9-15 classic file Upload class **/if (! Empty ($ _ POST [& amp; #39; sub & amp; #39;]) {includ... "> <LI
I wrote a classic file Upload class for you in the class, and the flexibility is also acceptable. for your reference,
Upload files:
Upload class: F_size = $ size * 1000000; $ this-> f_sys = $ sys; $ this-> f_name = $ name; $ this-> f_dir = $ dir; $ this-> f_mv () ;}// determine the file size function is_size () {if ($ this-> f_sys ['size'] <= $ this-> f_size) {return true;} else {return false;} // Determine the file type and return the function is_type () extension () {switch ($ this-> f_sys ['type']) {case "image/x-png": $ OK = ". png "; break; case" image/png ": $ OK = ". png "; break; case" application/pdf ": $ OK = ". pdf "; break; case" image/p Jpeg ": $ OK = ". jpg "; break; case" image/jpeg ": $ OK = ". jpg "; break; case" image/jpg ": $ OK = ". jpg "; break; default: $ OK = false; break;} return $ OK;} // terminate function f_over ($ n) {echo $ n; exit ();} // Determine whether the folder exists and create function is_dirs () {if ($ this-> f_dir) {if (! Is_dir ($ this-> f_dir) {mkdir ($ this-> f_dir);} return $ this-> f_dir;} else {if (! Is_dir (date ("Ymd") {mkdir (date ("Ymd");} return date ("Ymd") ;}// file name definition, use the timestamp function is_name () {if ($ this-> f_name) {$ fn = $ this-> f_name. $ this-> is_type ();} else {$ fn = time (). rand (100,999 ). $ this-> is_type ();} return $ this-> is_dirs (). "/". $ fn;} // upload the file function f_mv () {$ this-> is_size ()? Null: $ this-> f_over ("the file size exceeds"); $ this-> is_type ()? Null: $ this-> f_over ("incorrect file type"); move_uploaded_file ($ this-> f_sys ['tmp _ name'], $ this-> is_name ();} // complete the watermark, and so on.}?>