照片上传和显示PHP,MySQL

时间:2012-05-31 14:58:56

标签: php mysql image upload

我有一个图片上传脚本如下:

$product = $_POST['name'];
$detail = $_POST['detail'];
$price = $_POST['price'];
$class = $_POST['class'];
$category = $_POST['category'];
$name = $_FILES['image']['name'];
$tmpName  = $_FILES['image']['tmp_name'];


if ($name) {
    //start upload process
    $location = "images/" . $name;
    move_uploaded_file($tmpName, $location);
}


$query="INSERT INTO shop_products VALUES ('','$product','$location','$detail','$price','$class','$category','yes')";
$result=mysql_query($query) or die(mysql_error());

header("location: ../admin/index.php");

,图像显示如下:

<img class="item-img" src="scripts/images/<? echo $image; ?>" />

如您所见,如果您访问ltyboards.com/boards,文档源会为图像提供相应的文件名,并且图像确实存在于服务器上,但不会显示任何内容。想法?

1 个答案:

答案 0 :(得分:2)

看起来你的路径错了

scripts/images/images/

应该是

scripts/images/