我正在通过简单的php和html代码制作一个简单的图像上传事件或函数,尽管我没有遇到任何错误,但是我在名为“ uploads”的文件夹中看不到上传的图像,我该怎么办?
.... html
<!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>";
}
}
唯一的错误是,我无法看到我上传的图片