This is a simple PHP image upload class with image display code. It can be said to be the simplest upload class to upload files. You can set the height and width of the image to be displayed, the file size, etc.
This is a simple php tutorial image upload class with image display code. It should be said to be the simplest upload class to upload files. You can set the height and width of the image to be displayed, the file size, etc.
uploadimg.class.php file
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; //The width of the image to be displayed
var $image_h=350; //The width of the image to be displayed High
var $upload_file_size;
var $upload_must_size= 50000; //Allow the size of uploaded files, 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 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"]; //Upload The size of the 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:www.bkjia.comupload/".$this->upload_server_name;
move_uploaded_file($this- >upload_tmp_address,$this->file_server_address);//Move out of the temp directory
echo("file_server_address width=$this->image_w height=$this-> image_h/>"); //Display image
}
else
{
echo("File size is too large");
}
}
else
{
echo("This file type is not supported, please select again");
}}
}
html upload code
Call method
upload.php
inlcude('uploadimg.class.php');
$dd = new upload;
$dd->upload_file();