新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
php移動(dòng)文件失敗怎么辦
本文操作環(huán)境:Windows7系統(tǒng)、php7.1版、Dell G3電腦。

php 移動(dòng)文件失敗怎么辦?
php文件上傳,提示移動(dòng)文件失?。?/p>
如:
上傳。';
if (!isset($_FILES['upfile'])) $err_msg='表單不完全'.$err_msg_behind;
else $fileImg=$_FILES['upfile'];
switch($fileImg['Error']){
case 1:
$err_msg='文件超過(guò)最大上傳限制'.$err_msg_behind;
break;
case 3:
$err_msg='文件上傳不完全'.$err_msg_behind;
break;
case 4:
$err_msg='沒(méi)有選擇文件'.$err_msg_behind;
break;
case 2:
$err_msg='文件超過(guò)頁(yè)面最大上傳限制'.$err_msg_behind;
break;
case 7:
$err_msg='文件寫(xiě)入失敗'.$err_msg_behind;
break;
case 6:
$err_msg='沒(méi)有臨時(shí)文件夾'.$err_msg_behind;
break;
case 0:
break;
default:
$err_msg='未知錯(cuò)誤'.$err_msg_behind;
}
if (!in_array($fileImg['type'],array('image/jpeg','image/pjpeg','image/png'))) $msg="只允許上傳png或jpg圖片".$err_msg_behind;
if (!$err_msg){
if (!move_uploaded_file($fileImg['temp_name'],$dir.$fileImg['name'])){
$err_msg='移動(dòng)文件失敗'.$err_msg_behind;
}
}
if ($err_msg) error ($err_msg);
else{
echo '完成';
}
include("../Include/Close.php");
?>
解決辦法:
if (!move_uploaded_file($fileImg['temp_name'],$dir.$fileImg['name'])){
$err_msg='移動(dòng)文件失敗'.$err_msg_behind;
}
move_upload_file無(wú)法移動(dòng)文件
1、請(qǐng)確定$dir.$fileImg['name']的文件路徑是否正確
$dir=$file_upload_root.'HeadImages'最后是否要加"/"
2、請(qǐng)確定$dir具有可寫(xiě)權(quán)限
本文標(biāo)題:php移動(dòng)文件失敗怎么辦
新聞來(lái)源:http://m.fisionsoft.com.cn/article/ccoisee.html


咨詢
建站咨詢
