我正在尝试将我的文件保存在根目录中。但我一直低于错误。
警告:move_uploaded_file(../upload/dddd1.png) [function.move-uploaded-file]:无法打开流:/Applications/MAMP/htdocs/test-website/process/uploadchecker.php 中没有这样的文件或目录在第 48 行
我想将图像保存到:/Applications/MAMP/htdocs/test-website/uploads
下面是我的php代码。
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["upload_file"]["name"]));
if ((($_FILES["upload_file"]["type"] == "image/gif")|| ($_FILES["upload_file"]["type"] == "image/jpg")||($_FILES["upload_file"]["type"] == "image/jpeg")|| ($_FILES["upload_file"]["type"] == "image/png"))&& ($_FILES["upload_file"]["size"] < 200000)&& in_array($extension, $allowedExts)){
if ($_FILES["upload_file"]["error"] > 0){
echo "Error: " . $_FILES["upload_file"]["error"] . "<br />";
}else{
echo "Upload: " . $_FILES["upload_file"]["name"] . "<br />";
echo "Type: " . $_FILES["upload_file"]["type"] . "<br />";
echo "Size: " . ($_FILES["upload_file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["upload_file"]["tmp_name"];
if (file_exists("../uploads/" . $_FILES["upload_file"]["name"]))
{
echo $_FILES["upload_file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["upload_file"]["tmp_name"],"../upload/" . $_FILES["upload_file"]["name"]);
echo "Stored in: " . "../uploads/" . $_FILES["upload_file"]["name"];
}
}
}else{
echo "Invalid file";
}