This is a php file upload class with pictures displayed. In fact, it is possible to make a function. But it's still a little fun to do. ~ ~ ~
You should have used JS to verify the upload file type. But too lazy to do it.
<title>Untitled Document</title>
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; To display the width of the picture
var $image _h=350; To display the height of the picture
var $upload _file_size;
var $upload _must_size= 50000; Allow upload of file size, set yourself
function Upload_file ()
{
$this->upload_name = $_files["File" ["Name"]; Get 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 temporary address
$this->file_type = Array ("Image/gif", "image/pjpeg"); Types of files allowed to upload
$this->upload_file_size = $_files["File" ["Size"]; Size of 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:\usr\www\html\upload/". $this->upload_server_name;
Move_uploaded_file ($this->upload_tmp_address, $this->file_server_address);//Remove from temp directory
Echo ("File_server_address width= $this->image_w height= $this->image_h/>"); Show pictures
}
Else
{
Echo ("File size is too large");
}
}
Else
{
Echo ("Do not support this file type, please re-select");
}
}
}
$DD = new Upload;
$dd->upload_file ();
?>
The above introduces the free image upload php image upload class with the picture display, including the content of free image upload, I hope that the PHP tutorial interested friends helpful.