Home  >  Article  >  Backend Development  >  PHP example: Program source code to implement file upload_PHP tutorial

PHP example: Program source code to implement file upload_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:30:08797browse

How to upload files?



File upload interface CENTER>
if($UploadAction){
$UploadAction=0;
$TimeLimit=60;
/*Set the timeout limit time. The default time is 30s and set to 0 Time is unlimited*/
set_time_limit($TimeLimit);
If(($Upfile != "none")&&
($Upfile != ""))
{
$ Filepath="d:webwebphp est"; //Upload file storage path
$FileName=$Filepath.$Upfile_name;
if($Upfile_size <1024) //Upload file size
{$FileSize = (string)$Upfile_size . "bytes";}
elseif($Upfile_size <(1024 * 1024))
{
$FileSize = number_format((double)($Upfile_size / 1024), 1 ) . " KB";
}
else
{
$FileSize = number_format((double)($Upfile_size/(1024*1024)),1)."MB";
}
if(!file_exists($FileName))
{
if(copy($Upfile,$FileName))
{unlink($Upfile);
echo "

";
echo "File $Upfile_name has been uploaded successfully! ";
echo "

";
echo "File location: $FileName";
echo "

";
echo "File size: $FileSize";
echo "

";
}
else
{echo "File $Upfile_name failed to upload! "; }
}
else
{echo "The file $Upfile_name already exists! "; }
}
else
{echo "You did not select any files to upload! "; }
set_time_limit(30); //Restore the default timeout setting
}
?>
ACTION = "default.php" METHOD = "POST">



< ;/TR>





http://www.bkjia.com/PHPjc/509205.html

truehttp: //www.bkjia.com/PHPjc/509205.htmlTechArticleHow to implement file upload? HTML HEAD TITLE file upload interface/TITLE /HEAD BODYTABLECENTER? if($UploadAction){ $ UploadAction=0; $TimeLimit=60; /*Set the timeout limit and the default time is...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn