<?php
if (isset($_FILES['file'])) {
$file_name = $_FILES['file']['name'];
$file_tmp = $_FILES['file']['tmp_name'];
$upload_folder = "images/";
$move_file = move_uploaded_file($file_tmp, "$upload_folder/$file_name");
if ($move_file) {
echo "The file has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
<!DOCTYPE html>
<html>
<body>
<form method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="file" id="file">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
这是欧元 警告:move_uploaded_file(images // 489452.jpg):无法打开流:在/Applications/XAMPP/xamppfiles/htdocs/ncs_project/test.php的第7行,权限被拒绝
警告:move_uploaded_file():无法将'/ Applications / XAMPP / xamppfiles / temp / php5kvoOW'移动到/Applications/XAMPP/xamppfiles/htdocs/ncs_project/test.php中的'images // 489452.jpg'中7
答案 0 :(得分:1)
更改图像文件夹的读写权限
答案 1 :(得分:0)
使用此代码上传图片,它将在上传图片之前创建具有读写权限的文件夹:
if(!File::isDirectory($path)){
File::makeDirectory($path, 0777, true, true);
}
$image_path = Storage::disk('public')->put('iamges', $request->file('file'));