Free image upload php image upload class with picture display

Source: Internet
Author: User
Tags php file upload upload php
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.