电脑安全

您当前的位置:主页 > 电脑安全 >

PHP图片上传代码 2-网络编程

来源:[db:来源]标题:   上传文件    编辑:电脑技术全能网 时间:2019-09-20 06:24

原标题: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();?><center><formid="form1"name="upload"enctype="multipart/form-data"method="post"action="index.php?controler=userinfo&action=image">上传文件:<br><inputtype="hidden"name="MAX_FILE_SIZE"/><inputname="file"type="file"style="width:200;border:1solid#9a9999;font-size:9pt;background-color:#ffffff"size="17"><inputtype="submit"name="Submit"value="上传"style="width:30;border:1solid#9a9999;font-size:9pt;background-color:#ffffff"size="17"><br><br><br>同意上传的文件范例为:jpg|jpeg|png|pjpeg|gif|bmp|x-png|swf<br><br><ahref="index.php">前往</a></form>

上一篇:php实现文件下载的一段代码-网络编程

下一篇:没有了