一个简单上传文件出错的解决_PHP教程
刚开始的程序代码如下:
uploadimg.php(做为现在的主流开发语言)
(做为现在的主流开发语言)
//判断是上载界面还是实现界面,如果是上载界面,显示下面的HTML页面
if(!$_POST[UploadAction]):
?>
(做为现在的主流开发语言)
//如果是实现页面,显示下面的HTML页面,并激活php(做为现在的主流开发语言)脚本
else:
?>
(做为现在的主流开发语言)
//www.knowsky.com初始化UploadAction的状态
$UploadAction=0;
$UploadFile=$_POST[UploadFile];
if(($UploadFile!="none") && ($UploadFile!=""))
{
$UploadPath=$_SERVER[DOCUMENT_ROOT]."\";
if (!is_writeable($UploadPath))
{
echo "$UploadPath目录不可写!"; exit;
}
else
{
echo " $UploadPath 目录可写!";
}
$FileName=$UploadFile_name;
if($UploadFile_size {
$FileSize=(string)$UploadFile_size."字节";
}
elseif($UploadFile_size {
$FileSize=number_format((double)($UploadFile_size/1024),1)."KB";
}
else
{
$FileSize=number_format((double)($UploadFile_size/(1024*1024)),1)."KB";
}
if(!file_exists($UploadPath.$FileName))
{
if(move_uploaded_file($UploadFile,$UploadPath.$FileName))