PHP Upload method (class ). It is very simple. I often used the PHP method last time. I took it out from the class and it can be used directly or further improved, in the PHP100 video tutorial, I also explained in detail a very simple PHP Upload method, which is commonly used in the last PHP method. I used it for you from the class. it can be used directly, or you can continue to improve it, the bkJia video tutorial also details the PHP Upload method. For more information, see
/**
* Image Upload method-source and bkJia
* $ Maxsize = 500000 = 500 k;
* $ Updir = "up /";
* $ Upfile = $ _ FILES ["file_img"];
*/
Public function Get_file_upload ($ upfile, $ maxsize, $ updir, $ newname = date ){
If ($ newname = date)
$ Newname = date ("Ymdhs"); // use date as the file name
$ Name = $ upfile ["name"];
$ Type = $ upfile ["type"];
$ Size = $ upfile ["size"];
$ Tmp_name = $ upfile ["tmp_name"];
Switch ($ type ){
Case image/pjpeg:
Case image/jpeg:
$ Extend = ". jpg ";
Break;
Case image/gif:
$ Extend = ". gif ";
Break;
Case image/png:
$ Extend = ". png ";
Break;
}
If (empty ($ extend )){
The echo file type is incorrect. only jpg gif png format can be used;
}
If ($ size> $ maxsize ){
$ Maxpr = $ maxsize/1000;
Echo "Warning! The size of the uploaded image cannot exceed ";
}
If (move_uploaded_file ($ tmp_name, $ updir. $ newname. $ extend )){
Return $ newname. $ extend;
}
}
...