? PHP
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 a picture
var $image _h = the ; // to display the height of the picture
var $upload _file_size ;
var $upload _must_size = 50000 ; // allow file size to be uploaded, 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 a 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 Success, thank you for your support " );
$this -> file_server_address = " ./upload/tx/ " . $this -> Upload_server_name;
Move_uploaded_file ( $this -> upload_tmp_address , $this -> file_server_address); // moving out of the temp directory
Echo ( " file_server_address width= $this->image_w height= $this->image_h/> " ); // Show Pictures
}
Else
{
Echo ( " file capacity is too large " );
}
}
Else
{
Echo ( " This file type is not supported, please select again " );
}
}
}
?>
? PHP
include ( '' ./lib/wodream/image/image_upload.php '' );
$DD = New upload;
$DD -> Upload_file ();
?>
< Center >< form ID = "Form1" name = "Upload" enctype = "Multipart/form-data" method = "POST" Action = "Index.php?controler=userinfo&action=image" >
Upload file: < BR >< input type = "hidden" name = "Max_file_size" />
< input name = "File" type = "File" style = "Width:200;border:1 solid #9a9999; font-size:9pt background-color: #ffffff" size = "a" >
< input type = "Submit" name = "Submit" value = "Upload" style = "Width:30;border:1 solid #9a9999; font-size:9pt background-color: #ffffff" size = "a" >< BR >< BR >< BR >
The file types that are allowed to upload are: jpg|jpeg|png|pjpeg|gif|bmp|x-png|swf < BR >< BR >
< a href = "index.php" > return </ a >
</ form >