gpt4 book ai didi

php - 上传图片到服务器时打开流失败

转载 作者:搜寻专家 更新时间:2023-10-30 23:39:20 25 4
gpt4 key购买 nike

我正在将图像上传到我的服务器。我正在使用以下 脚本:

<?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");
}

}

?>

我的代码有一些问题。我收到多个错误。

failed to open stream: No such file or directory in C:\xampp\htdocs\nipu\file upload\saveimage.php on line 29

Warning: move_uploaded_file(images/03-05-2016-1462289806.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\nipu\file upload\saveimage.php on line 29

Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\phpF912.tmp' to 'images/03-05-2016-1462289806.jpg' in C:\xampp\htdocs\nipu\file upload\saveimage.php on line 29

这里有什么问题?

最佳答案

  1. 设置完整路径$target_path
  2. 检查目标文件夹是否存在?
  3. 同时为该文件夹设置“写入”权限。

关于php - 上传图片到服务器时打开流失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36996193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com