Home >Backend Development >PHP Tutorial >A solution to a simple file upload error_PHP tutorial
I didn’t pay much attention to file uploading before. Yesterday I did a simple one but found that there were quite a lot of problems.
The initial program code is as follows:
uploadimg.php(as the current mainstream development language)
(as Current mainstream development languages)
//Determine whether it is an upload interface or an implementation interface. If it is an upload interface, display the following HTML page
if(!$_POST[UploadAction]):
?>
(as the current mainstream development language)
//If it is an implementation page, display the following HTML page, And activate php(as the current mainstream development language)script
else:
?>
(as the current mainstream development language)
//www.knowsky.com initializes the status of UploadAction
$UploadAction=0;
$UploadFile=$_POST[UploadFile];
if(($UploadFile!="none") && ($UploadFile!=""))
{
$UploadPath=$_SERVER[DOCUMENT_ROOT]."";
if (!is_writeable ($UploadPath))
"$UploadPath directory is writable!";
}
$FileName=$UploadFile_name;
if($UploadFile_size<1024)
{
}
elseif($UploadFile_size<(1024*1024)) KB";
}
else
{
$FileSize=number_format((double)($UploadFile_size/(1024*1024)),1)."KB"; if(!file_exists($ UploadPath.$FileName))
http://www.bkjia.com/PHPjc/508724.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/508724.html
TechArticle