Up. class. php & lt ;? Phpclassup {public $ f; // indicates $ _ FILES [xx] public $ s; // The size of the uploaded file is public $ n; // specifies whether the file name is public $ d; // specify the folder function _ construct ($ f, $ s = 1, $ n = false, $ d
Up. class. php
F = $ f; $ this-> s = $ s * 1000000; $ this-> n = $ n; $ this-> d = $ d; $ this-> loading ();} function loading () {$ this-> fsize (); $ this-> ftype (); $ this-> fmv ();} function fname () {if ($ this-> n) {return $ this-> n. $ this-> ftype ();} else {return time (). rand (111,999 ). $ this-> ftype () ;}} function fdir () {if ($ this-> d) {// Determine whether the user specifies the folder name if (! Is_dir ($ this-> d) {// determines whether the specified folder name contains mkdir ($ this-> d);} return $ this-> d. "/";} else {if (! Is_dir (date ("Ymd") {mkdir (date ("Ymd");} return date ("Ymd "). "/" ;}}// end fdir function fsize () {if ($ this-> f ['size']> $ this-> s) {echo "file size exceeded"; exit () ;}else {return true ;}} function ftype () {switch ($ this-> f ['type']) {case "image/x-png": $ OK = ". png "; break; case" image/png ": $ OK = ". png "; break; case" application/pdf ": $ OK = ". pdf "; break; case" image/pjpeg ": $ OK = ". jpg "; break; case" image/jpeg ": $ OK = ". jpg "; break; Case "image/jpg": $ OK = ". jpg "; break; default: $ OK = false; break;} if ($ OK) {return $ OK;} else {echo" incorrect file type "; exit () ;}} function fmv () {move_uploaded_file ($ this-> f ['tmp _ name'], $ this-> fdir (). $ this-> fname () ;}}?> Upload files using test. php$ V) {new up ($ _ FILES [$ id]) ;}}?>