我无法从简单的html和php代码中看到上传的图像
我正在用简单的php和html代码制作一个简单的图像上传事件或函数,虽然我没有收到任何错误,但我无法在名为“uploads”的文件夹中看到我上传的图像,我该怎么办 …html我无法从简单的html和php代码中看到上传的图像,php,html,Php,Html,我正在用简单的php和html代码制作一个简单的图像上传事件或函数,虽然我没有收到任何错误,但我无法在名为“uploads”的文件夹中看到我上传的图像,我该怎么办 …html <!DOCTYPE html> <html> <head> <title>prasad</title> </head> <body> <form action="upload.php" method="POST" en
<!DOCTYPE html>
<html>
<head>
<title>prasad</title>
</head>
<body>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit" name="submit">upload</button>
</form>
</body>
</html>
...html
...php
<?php
if (isset($_POST['submit'])){
$file = $_FILES['file'];
print_r($file);
echo "<br>";
$fileName = $_FILES['file']['name'];
$fileType=$_FILES['file']['type'];
$file_temp_name=$_FILES['file']['tmp_name'];
$file_error=$_FILES['file']['error'];
$file_size=$_FILES['file']['size'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('jpg','jpeg','png','pdf');
if (in_array($fileActualExt, $allowed)) {
if ($file_error === 0) {
if ($file_size<1000000){
$fileNameNew = uniqid('',true).".".$fileActualExt;
$fileDestination = 'uplaods/'.$fileNameNew;
move_uploaded_file($file_temp_name, $fileDestination);
header("Location: pp.php?success");
}else {
echo "this is too big file";
}
# code...
}else{
echo "there was an error ..!";
}
}else{
echo "<h1>you couldnt choose any file..</h1>";
}
}
普拉萨德
上传
…html
…php
我看到了您的代码:$fileDestination='uplaods/'。$filenamew
你应该检查move\u uploaded\u file()的返回值。
我看到你的代码很完美,它对我很有用。可能您上传的文件夹路径不正确,请检查文件夹路径。我还看到,在您使用action=“upload.php”的表单中,文件名是否正确?请再次检查,否则将操作设置为空白。您可能没有名为“uplaods”的现有文件夹。也许你的名字叫“uploads”@Phil,虽然我创建了名为“uplaods”的文件夹,但我看不到上传的图像,请注意我使用的是ubuntu 18.04而不是windows。我看到了你的代码:$fileDestination='uplaods/。$filenamew
你应该检查move\u uploaded\u file()的返回值。
我看到你的代码很完美,它对我很有用。可能您上传的文件夹路径不正确,请检查文件夹路径。我还看到,在您使用action=“upload.php”的表单中,文件名是否正确?请再次检查,否则将操作设置为空白。您可能没有名为“uplaods”的现有文件夹。也许你的名字叫“uploads”@Phil,虽然我创建了一个名为“uplaods”的文件夹,但我看不到上传的图片,请注意我使用的是ubuntu 18.04,而不是windows。。