<?php
if($_FILES['img']['error']>0){
echo "Error: No file selected!";
}
else {
echo "File name ".$_FILES['img']['name']."<br>";
echo "File size ".round($_FILES['img']['size'] / 1024,1)." kb <br>";
echo "File type ".$_FILES['img']['type']."<br>";
echo "File tmp ".$_FILES['img']['tmp_name']."<br>";
$extension = end(explode(".",$_FILES['img']['name']));
echo "file format: ".$extension."<br>";
$name = $_FILES['img']['name'];
$size = $_FILES['img']['size'];
if(file_exists("uploads/".$name)){
echo $_FILES['img']['name']." exists";
}
if($extension != "jpg" && $extension != "png" && $extension != "gif"){
echo "File with format: ".$extension." is not aviable to upload";
}
if($size > 1000000) {
echo $size." is greater than 1 mb !";
}
elseif(empty($name)) {
echo "No file selected!";
}
elseif($extension != "jpg" && $extension != "png" && $extension != "gif" && $_FILES['img']['size'] > 1000000 && file_exists("uploads/".$name)){
echo $name." exists";
echo "File with format: ".$extension." is not aviable to upload";
echo $size." is greater than 1 mb !";
}
else {
move_uploaded_file($_FILES['img']['tmp_name'],"uploads/".$name);
echo "The file was succesfully uploaded";
}
}
?>
嘿,我正在尝试上传文件......但它显示错误:
警告:move_uploaded_file(uploads/51.jpg) [function.move-uploaded-file]:打开流失败:Z:\home\test1.ru\www\views\admin\save.php 中没有这样的文件或目录第 35 行
警告:move_uploaded_file() [function.move-uploaded-file]:无法将 'Z:\tmp\phpB178.tmp' 移动到 Z:\home\test1.ru\www\views\ 中的 'uploads/51.jpg'第 35 行的 admin\save.php
而且ofc它不上传文件..这有什么问题?