Home  >  Article  >  Backend Development  >  A solution to a simple file upload error_PHP tutorial

A solution to a simple file upload error_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:32:18886browse

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]):

?>










                                                                                                             name="reset" value="Reset">


(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)
{

$FileSize =(string)$UploadFile_size."Bytes";

}

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

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