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.
< html xmlns="http://www.w3.org/1999/xhtml">
Untitled Document 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; //Width of the image to be displayed
var $image_h=350 ; //To display pictures The high
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 upload 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"]; //Get the temporary address
$this->file_type = array("image/gif","image/pjpeg"); //Types of files allowed to be uploaded
$this->upload_file_size = $_FILES["file"]["size"]; //Size of uploaded files
if(in_array($this->upload_filetype,$this-> ; file_type) {if ($ this- & gt; upload_file_size & lt; $ this- & gt; upload_must_size) {
echo ("" Upload success, thank you for support "); _Server_Address = "D: USRWWHTMLUPLOAD/ ". $ this- & gt; upload_server_name;
move_uploaded_file ($ this- & gt; upload_tmp_address, $ this- & gt; file_server_address); // The directory moves
echo ("& lt; img src = $ this-& gt; file_server_address width = $this->image_w height=$this->image_h/>"); //Display image
using using using using through out through out through out through out through out out through out out of ’s ‐ to ‐ ‐‐ ‐‐‐‐‐ and � to
else
{
echo("This file type is not supported, please select again");
}
}
}
$dd = new upload;
$dd->upload_file();
?>
The above introduces the free image upload PHP image upload class with image display, including the content of free image upload. I hope it will be helpful to friends who are interested in PHP tutorials.