我无法弄清楚我在php上的文件上传出了什么问题。
php代码:
<?php
session_start();
if ($_SESSION['Loggedin']!="Yes") {
header('location:index.php');
exit();
}
require_once('Connect.php');
//This is the directory where images will be saved
$target = "../htdocs/sites/tryouts/newgames/images/main-news/";
$target = $target . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$author=$_POST['author'];
$title=$_POST['title'];
$pic=($_FILES['photo']['name']);
$bericht=$_POST['bericht'];
//Writes the information to the database
mysqli_query($Connection, "INSERT INTO nieuws (Nieuws_Author,Nieuws_Title,Nieuws_Image,Nieuws_Bericht)
VALUES ('$author', '$title', '$pic', '$bericht')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
我收到2个错误:
警告: move_uploaded_file(../的htdocs /网站/选拔赛/ newgames /图片/主新闻/ bandicam 2014-05-2919-48-59-499.jpg):无法打开流:没有这样的文件或 目录 C:\ Users \ xammp \ htdocs \ sites \ tryouts \ newgames \ addnewsscripts.php on 第26行
和
警告:move_uploaded_file():无法移动 'C:\ Users \ xammp \ tmp \ php24D.tmp'来 '../htdocs/sites/tryouts/newgames/images/main-news/bandicam 2014-05-29 19-48-59-499.jpg'in C:\ Users \ xammp \ htdocs \ sites \ tryouts \ newgames \ addnewsscripts.php on 第26行抱歉,上传文件时出现问题。
我已经检查过php文件上传设置,目录是:
你能搞清楚我做错了什么吗? probaly它是我想放置我的图像的目录,但我需要使用哪个目标目录?upload_tmp_dir =“C:\ Users \ xammp \ tmp”
答案 0 :(得分:0)
所以,如果我们有
//This is the directory where images will be saved
$target = "../htdocs/sites/tryouts/newgames/images/main-news/";
错误
警告:move_uploaded_file():无法移动 'C:\ Users \ xammp \ tmp \ php24D.tmp' to '../ htdocs / sites / tryouts / newgames / images / main-news / bandicam 2014-05-29 19-48-59-499.jpg'in C:\ Users \ xammp \ htdocs \ sites \ tryouts \ newgames \ addnewsscripts.php on 第26行抱歉,上传文件时出现问题。
我会说你需要改变你的路径
$target = "C:\Users\xammp\htdocs\sites\tryout\newgames\images\main-news\";