[英]PHP - Check if destination is writeable
我正在嘗試使用php將圖像上傳到服務器上的文件夾,但出現此錯誤消息:
Warning: move_uploaded_file(): Unable to move '/Applications/XAMPP/xamppfiles/temp/phpPoVMRg' to 'userImages/Test/Test 2.jpg' in /Applications/XAMPP/xamppfiles/htdocs/TestSite/upload.php on line 16
Error uploading file - check destination is writeable.
似乎有一些阻止上傳。 我的猜測是操作系統,但是我不確定如何允許可寫性。
我將Mac與OS X優勝美地一起使用。
這也是上傳代碼:
<?php
session_start();
// Check for errors
if($_FILES['file_upload']['error'] > 0){
die('An error ocurred when uploading.');
}
if(!getimagesize($_FILES['file_upload']['tmp_name'])){
die('Please ensure you are uploading an image.');
}
// Upload file
if(!move_uploaded_file($_FILES['file_upload']['tmp_name'], 'userImages/Test/' . $_FILES['file_upload']['name'])){
die('Error uploading file - check destination is writeable.');
}
die('File uploaded successfully.');
?>
感謝您的回答!
使用is_writable函數
if (is_writable($directory)) {
echo 'I can write here';
} else {
echo 'I can not write here';
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.