社区交流

PHP图片上传代码 2

?phpClassupload{var$upload_name;var$upload_tmp_address;var$upload_server_name;var$upload_filetype;var$file_type;var$file_server_address;var$image_w=900;//要显示图片的宽var$image_h=350;//要显示图片的高var$upload_file_size;var$upload_must_size=50000;//允许上传文件的大小,自己设置functionupload_file(){$this-upload_name=$_FILES[file][name];//取得上传文件名$this-upload_filetype=$_FILES[file][type];$this-upload_server_name=date(Y_m_dH_i_s).$this-upload_name;$this-upload_tmp_address=$_FILES[file][tmp_name];//取得临时地址$this-file_type=array(image/gif,image/pjpeg);//允许上传文件的类型$this-upload_file_size=$_FILES[file][size];//上传文件的大小if(in_array($this-upload_filetype,$this-file_type)){if($this-upload_file_size$this-upload_must_size){echo(上传成功,谢谢支持);$this-file_server_address=./upload/tx/.$this-upload_server_name;move_uploaded_file($this-upload_tmp_address,$this-file_server_address);//从TEMP目录移出echo(imgsrc=$this-file_server_addresswidth=$this-image_wheight=$this-image_h/);//显示图片}else{echo(文件容量太大);}}else{echo(不支持此文件类型,请重新选择);}}}??phpinclude(”./lib/wodream/image/image_upload.php”);$dd=newupload;$dd-upload_file();?centerformid=form1name=uploadenctype=multipart/form-datamethod=postaction=index.php?controler=userinfoaction=image上传文件:brinputtype=hiddenname=MAX_FILE_SIZE/inputname=filetype=filestyle=width:200;border:1solid#9a9999;font-size:9pt;background-color:#ffffffsize=17inputtype=submitname=Submitvalue=上传style=width:30;border:1solid#9a9999;font-size:9pt;background-color:#ffffffsize=17brbrbr允许上传的文件类型为:jpg|jpeg|png|pjpeg|gif|bmp|x-png|swfbrbrahref=index.php返回/a/form

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章