首先我想爲這個問題道歉,因爲我知道已經有很多人問這個問題了。但我搜索的所有答案都沒有解決我的問題。所以希望你考慮這個問題並幫助我解決這個問題。在上傳php文件時出現錯誤(圖片)
所以基本上我試圖上傳的圖片文件,當我提交,錯誤彈出:
Warning: move_uploaded_file(./images/jarvs.jpg): failed to open stream:
Warning: move_uploaded_file(): Unable to move 'C:\wamp\tmp\phpA25F.tmp' to './images/jarvs.jpg'
我真的不明白的錯誤,但我知道,錯誤當我嘗試從圖像的路徑傳輸圖像,並將其發送到我的目標文件夾(目標路徑)時發生的
因此繼承我的代碼:
HTML: <input id="profimagefile" name="profileimage" class="input-file" type="file">
PHP:
$targetPath = "images/";
$targetPath = $targetPath.basename($_FILES['profileimage']['name']);
//name of the file
$img = $_FILES['profileimage']['name'];
$size = $_FILES['profileimage']['size'];
$type = $_FILES['profileimage']['type'];
if(move_uploaded_file($_FILES['profileimage']['tmp_name'], $targetPath))
{
$queryupload = "INSERT INTO images_profile (image_name, image_path, date_uploaded, emailAddress)
VALUES ('$img', '$targetPath','$registerDate', '$email')";
mysqli_query($conn, $queryupload);
echo "The file ". basename($_FILES['profileimage']['name']). " has been uploaded." . "<br/>";
}
else {
echo "Sorry, there was a problem uploading your file." . "<br/>";
}
不介意數據庫的接入,它只是過程的一部分後的圖像已經搬到我TARGETPATH。 感謝你回答
你給文件夾的權限 – rahul
有請檢查「images /」文件夾的權限 –
有什麼權限?我不明白。 –