我正在開發一個帶有文件上傳的Web應用程序。PHP文件上傳move_uploaded_file不起作用
我剛寫了一段php代碼來上傳圖片。
if(isset($_FILES['equipmentPictureName'])){
$file_tmp =$_FILES['equipmentPictureName']['tmp_name'];
$file_name = $_FILES['equipmentPictureName']['name'];
$uploads_dir = '/pic';
echo "on file upload if";
if(move_uploaded_file($file_tmp,$uploads_dir.$file_name)){
echo "uploaded";
exit();
}else
{
echo "error on upload";
exit();
}
}else{
echo "File Not Present";
exit();
}
當我運行這段代碼,我可以在文件上傳得到像輸出在上傳錯誤
我給777權限PIC文件夾
問題是什麼,任何想法,,
表..
<form action="manage-ahri-action.php" method="post" name="equipment" enctype="multipart/form-data" id="multiple_upload_form" >
<div class="col-lg-6 col-sm-6 row" style="margin-bottom: 15px;">
<div class="form-group">
<label for="" class="col-lg-4 col-sm-4" style="text-align: right;">Equipment Picture</label>
<div class="col-lg-8 col-sm-8">
<div class="option-group uploading none">
<span class="file-button btn-primary" style="margin-right: 14px;">Choose File</span>
<input name="equipmentPictureName" type="file" class="form-control form-white"/>
</div>
</div>
</div>
</div>
<div class="file col-lg-12 col-sm-12 col-md-12">
<button type="submit" class="btn btn-primary btn-square" style="margin-top: 20px">Submit</button>
</div>
</form>
的print_r
陣列([equipmentPictureName] =>陣列([名稱] =>貓01.JPG [型] =>圖像/ JPEG [tmp_name的值] =>的/ tmp/php96PS5A [錯誤] => 0 [數組] => [數組] =>數組([數組] => 72413)[認可] =>數組([名稱] => [類型] => [tmp_name] => [錯誤] =>名] => [式] => [tmp_name的值] => [錯誤] => 4 [尺寸] => 0))
由於
'/'在'$ uploads_dir。$ file_name'之間它會是'$ uploads_dir。「/」。$ file_name' – Saty
不工作...我試過 –
請將您的表單代碼!!! – Saty