Php simple file Image Upload class
This file upload class can upload gif ",". jpg ",". jar ",". jad ",". mid ",". mp3 ",". mid ",". bmp ",". wav ",". rm ",". wmv file format. If you want to support other formats, you can design $ this-> file_type ,.
<? Php
Class upload {
Var $ file_type;
Var $ file_size;
Var $ file_name;
Var $ exname;
Var $ datetime;
Function up ($ post_name, $ path ){
$ This-> file_name = $ _ FILES [$ post_name] ["name"];
$ This-> exname = strtolower (substr ($ this-> file_name, strrpos ($ this-> file_name ,".")));
$ This-> file_size = $ _ FILES [$ post_name] ["size"];
$ This-> file_type = array (". gif ",". jpg ",". jar ",". jad ",". mid ",". mp3 ",". mid ",". bmp ",". wav ",". rm ",". wmv ");
$ This-> datetime = date ("YmdHis ");
If (! In_array ($ this-> exname, $ this-> file_type )){
Print ("<script language = 'javascript '> ");
Print ("alert ('format not supported! ');");
Print ("history. back ();");
Print ("</script> ");
Break;
} Else'if ($ this-> file_size> "50000 "){
Print ("<script language = 'javascript '> ");
Print ("alert ('the image size cannot exceed 50KB! ');");
Print ("history. back ();");
Print ("</script> ");
Break;
} Else {
Move_uploaded_file ($ _ FILES [$ post_name] ["tmp_name"], $ path. $ this-> datetime. $ this-> exname );
}
}
Function fileName (){
$ Pic = $ this-> datetime. $ this-> exname;
Return $ pic;
}
}
?>