(图像尚未找到)图像在网站位于Web主机时上传到数据库

时间:2015-07-08 18:47:17

标签: php mysql image-processing hosting

此代码在我的localhost上运行。使用localhost wampserver将图像上传到我的mysql服务器。一切似乎都很好。但是当我将代码迁移到托管站点时,我无法看到在mysql服务器上传的图像。我所能看到的只是我的路径" images-storage /"作为"照片"的价值列,"图像存储"是空的,没有存储图像。

这是代码:

我的表格:

<form action="add.php" method="POST" enctype="multipart/form-data">
    Firstname: <input type="text" name="firstname"><br />
    Lastname: <input type="text" name="lastname"><br /><br />
    <input type="file" name="image">
    <input type="submit" value="Submit">
</form>

我的表单行动:

<?php
    include_once('config.php');

    $fn = $_POST['firstname'];
    $ln = $_POST['lastname'];
    $name = $_FILES["image"]["name"];
    $type = $_FILES["image"]["type"];
    $size = $_FILES["image"]["size"];
    $temp = $_FILES["image"]["tmp_name"];
    $error = $_FILES["image"]["error"];

    if($error > 0) {
        echo "Error";
    } else {
        $add_image = move_uploaded_file($temp,"uploaded/".$name);
        $path = 'uploaded/'.$name;
        $query = $mysqli->query("INSERT INTO info(fn,ln,name,photo) VALUES('$fn','$ln','$name','$path')");  
    }

    header('Location: index.php');
?>

1 个答案:

答案 0 :(得分:0)

只需添加&#34; name&#34;数据库中的列。哈哈