<?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(图片//489452.jpg):未能打开流: /Applications/XAMPP/xamppfiles/htdocs/ncs_project/test.php拒绝7行的许可
警告:move_uploaded_file():无法将“/Applications/XAMPP/xamppfiles/temp/PHP 5 kvoow”移动到第7行的/Applications/XAMPP/xamppfiles/htdocs/NCS _ project/test . PHP中的“images//489452.jpg”
更改图像文件夹读写权限
使用此代码来上传您的图像,它会在上传图像之前创建一个具有读写权限的文件夹:
if(!File::isDirectory($path)){
File::makeDirectory($path, 0777, true, true);
}
$image_path = Storage::disk('public')->put('iamges', $request->file('file'));