一款简单PHP图片上传类带图片显示代码
      
     
                这是一款简单PHP图片上传类带图片显示代码,应该可以说是上传文件最简单的上传类了,可以设置要显示图片高度与宽度,文件大小等.
uploadimg.class.php文件,代码如下:
	
	- class upload  
- {  
- 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;  
- function upload_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 = "d:www.111cn.netupload/".$this->upload_server_name;  
- move_uploaded_file($this->upload_tmp_address,$this->file_server_address); 
- echo("<img src=$this->file_server_address width=$this->image_w height=$this->image_h/>");  
-  
-  
- }  
- else  
- {  
- echo("文件容量太大");  
- }  
- }  
- else  
- {  
- echo("不支持此文件类型,请重新选择");  
-  
- } 
-  
- } 
-  
- } 
html上传代码,代码如下:
	
	- <form id="form1" name="upload" enctype="multipart/form-data" method="post" action="upload.php">  
- <input type="hidden" name="max_file_size " />  
- <input type="file" name="file" />  
- <input type="submit" name="submit" value="提交" />  
- </form> 
调用方法,upload.php,代码如下:
	
	- inlcude('uploadimg.class.php'); 
- $dd = new upload;  
- $dd->upload_file();