Classic php file Upload class

Source: Internet
Author: User
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.}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.