所以我的php文件有问题,能够将图像上传到文件夹。我对php很新,所以我的行话有点生疏。此代码允许管理员用户通过添加文本字段和上传图像来将新产品添加到商店。文本很好,问题在于图像没有上传到指定的文件夹。数据库表识别已经发生了更新,但是下面列出了php代码,这就是它更新的方式......
http://i.imgur.com/CnloamI.png
非常感谢任何帮助:)
<?php
include('../connect.php');
$inserted = insert($_FILES['addimage1'], 'image1');
$inserted = insert($_FILES['addimage2'], 'image2');
$inserted = insert($_FILES['addimage3'], 'image3');
function insert($file, $image_col_name)
{
$addid= $_POST['addrow'];
$addproduct= mysql_real_escape_string(htmlentities($_POST['addproduct']));
$addprice= mysql_real_escape_string(htmlentities($_POST['addprice']));
$addprevprice= mysql_real_escape_string(htmlentities($_POST['addprevprice']));
$adddetails= mysql_real_escape_string(htmlentities($_POST['adddetails']));
$addimage = mysql_real_escape_string($file['name']);
$addimagetemp = mysql_real_escape_string($file['tmp_name']);
$addimagetype = mysql_real_escape_string($file['type']);
$addimagesize = mysql_real_escape_string($file['size']);
if (!empty($addimage))
{
if ($addimagetype == 'image/gif' || $addimagetype == 'image/jpg' || $addimagetype == 'image/jpeg' && $addimagesize > 0 && $addimagesize < 2000000)
{
move_uploaded_file($addimagetemp,"../img/camera/$addimage");
$query = "INSERT INTO admincamera (product, price, prevprice, details, $image_col_name)"."VALUES('$addproduct', '$addprice', '$addprevprice', '$adddetails', '$addimage')";
}
else
{
echo "<p>file needs to be a jpg/gif or file size too big.</p>";
die();
}
}
else
{
$query = "INSERT INTO admincamera (product, price, prevprice, details)"."VALUES('$addproduct', '$addprice', '$addprevprice', '$adddetails')";
}
mysql_query($query) or die(mysql_error());
return true;
}
?>
答案 0 :(得分:0)
我认为您需要设置目录权限,否则请提供您收到的错误消息。
答案 1 :(得分:0)
授予在目录中上传的权限,尝试在文件夹目录中运行chmod
chmod -R 777 image_folder