PHP image upload class with image display_PHP tutorial
WBOYOriginal
2016-07-21 16:00:12927browse
This is a PHP file upload class with image display. In fact, it can be made into a function. But it is more fun to make it into a class. ~~~~ I should have used JS to verify the uploaded file type. But I was too lazy to do it. .
Untitled Document
< form id="form1" name="upload" enctype="multipart/form-data" method="post" action="upload.php">
< ;/form>
Class upload { var $upload_name; var $upload_tmp_address; var $upload_server_name; var $upload_filetype; var $file_type; var $file_server_address; =350; //To display the height of the image var $upload_file_size; var $upload_must_size= 50000; //Allow the size of the uploaded file, set it yourself function upload_file() { $this->upload_name = $_FILES["file"]["name"]; //Get the name of the uploaded file $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"]; //Get temporary Address $this->file_type = array("image/gif","image/pjpeg"); //Types of files allowed to be uploaded $this->upload_file_size = $_FILES["file"] ["size"]; //The size of the uploaded file if(in_array($this->upload_filetype,$this->file_type)) { if($this->upload_file_size < $this ->upload_must_size) { echo("Upload successful, thank you for your support"); $this->file_server_address = "D:usrwwwhtmlupload/".$this->upload_server_name; Move_uploaded_file ($ this-& gt; upload_tmp_address, $ this- & gt; file_server_address); // Moles echo ("& lt; IMG sg s RC = $ this-& gt; file_server_address width = $ this- & gt; image_w height = $this->image_h/>"); //Display image
} else { echo("The file size is too large"); } } else { echo("This file type is not supported, please select again"); }
}
} $dd = new upload; $dd->upload_file(); ?>
http://www.bkjia.com/PHPjc/317215.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317215.htmlTechArticleThis is a PHP file upload class with image display. In fact, it can be made into a function. But still do it Classification is more fun.~~~~ I should have used JS to verify the uploaded file type. But I was too lazy to do it...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn