首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xampp php文件上传错误

xampp php文件上传错误
EN

Stack Overflow用户
提问于 2014-06-01 16:54:07
回答 1查看 1.5K关注 0票数 0

我不知道我的文件上传到php上出了什么问题。

php代码:

代码语言:javascript
复制
<?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.";
}
  ?>

我有两个错误:

警告: move_uploaded_file(../htdocs/sites/tryouts/newgames/images/main-news/bandicam 2014-05-2919-48-59-499.jpg):未能打开流:第26行C:\Users\xammp\htdocs\sites\tryouts\newgames\addnewsscripts.php中没有这样的文件或目录

警告:'../htdocs/sites/tryouts/newgames/images/main-news/bandicam ():无法将“C:\Users\xammp\tmp\php24D.tmp”移动到第26行C:\Users\xammp\htdocs\sites\tryouts\newgames\addnewsscripts.php中的move_uploaded_file 2014-05-29 19-48-59-499.jpg,对不起,上传您的文件有问题。

我已经检查了php文件上传的设置,dir是:

upload_tmp_dir = "C:\Users\xammp\tmp“

你能查出我做错了什么吗?很可能它是我想要放置图像的目录,但是我需要使用哪个目标目录呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-01 19:22:50

所以如果我们有

代码语言:javascript
复制
//This is the directory where images will be saved
$target = "../htdocs/sites/tryouts/newgames/images/main-news/";

和错误

警告:'C:\Users\xammp\tmp\php24D.tmp' ():无法将C:\Users\xammp\htdocs\sites\tryouts\newgames\addnewsscripts.php移动到第26行C:\Users\xammp\htdocs\sites\tryouts\newgames\addnewsscripts.php中的C:\Users\xammp\htdocs\sites\tryouts\newgames\addnewsscripts.php 2014-05-29 19-48-499.jpg‘对不起,上传您的文件有问题。

我想说的是你需要改变你的道路

代码语言:javascript
复制
$target = "C:\Users\xammp\htdocs\sites\tryout\newgames\images\main-news\";
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23982216

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档