[英]Failed to open stream when uploading image to server
我正在将图像图像上传到我的服务器。 我正在使用以下php脚本:
<?php
include("mysqlconnect.php");
function GetImageExtension($imagetype)
{
if(empty($imagetype)) return false;
switch($imagetype)
{
case 'image/bmp': return '.bmp';
case 'image/gif': return '.gif';
case 'image/jpeg': return '.jpg';
case 'image/png': return '.png';
default: return false;
}
}
if (!empty($_FILES["uploadedimage"]["name"])) {
$file_name=$_FILES["uploadedimage"]["name"];
$temp_name=$_FILES["uploadedimage"]["tmp_name"];
$imgtype=$_FILES["uploadedimage"]["type"];
$ext = GetImageExtension($imgtype);
$imagename=date("d-m-Y")."-".time().$ext;
$target_path = "images/".$imagename;
if(move_uploaded_file($temp_name, $target_path)) {
$query_upload="INSERT into 'images_tbl' ('images_path','submission_date') VALUES ('".$target_path."','".date("Y-m-d")."')";
mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error());
}else{
exit("Error While uploading image on the server");
}
}
?>
我的代码有一些问题。 我收到多个错误。
无法打开流:第 29 行 C:\\xampp\\htdocs\\nipu\\file upload\\saveimage.php 中没有这样的文件或目录
警告:move_uploaded_file(images/03-05-2016-1462289806.jpg): 无法打开流:第 29 行 C:\\xampp\\htdocs\\nipu\\file upload\\saveimage.php 中没有这样的文件或目录
警告:move_uploaded_file():无法将 'C:\\xampp\\tmp\\phpF912.tmp' 移动到 C:\\xampp\\htdocs\\nipu\\file upload\\saveimage 中的 'images/03-05-2016-1462289806.jpg'。第 29 行的 php
这里有什么问题?
$target_path
根据你的代码,你的目录结构是这样的
-nipu
--file upload
---saveimage.php
---images
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.