我的数据库中的图像不在我的网站上发布(PHP MySQL) [英] My image in my database is not posting on my site (PHP MySQL)

查看:136
本文介绍了我的数据库中的图像不在我的网站上发布(PHP MySQL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我创建了一个表单,它为两个文件按钮(对于图像)一个用于缩略图,另一个用于主图像,并且已经成功地将这些文件放入数据库中,并且已经获得了正确的目录。 ..但我有一个问题...当它的时间回声的图像,他们不显示出来...一些请帮助我



这里是窗体和代码(都在同一个文件中称为addimage.php):

 <?php 
include'includes / connect。 PHP的;

if($ _ POST ['submit'])
{
$ img =main /;
$ img = $ img。基名($ _ FILES [照片1’ ] [名称]);

$ tmb =thumb /;
$ tmb = $ tmb。基名($ _ FILES [照片2’ ] [名称]);


$ imagename = mysql_real_escape_string($ _ POST ['imagename']);
$ content = mysql_real_escape_string($ _ POST ['content']);
$ links = mysql_real_escape_string($ _ POST ['links']);
$ pic1 =main /。(mysql_real_escape_string($ _ FILES ['photo1'] ['name']));
$ pic2 =thumb /。(mysql_real_escape_string($ _ FILES ['photo2'] ['name']));

if(move_uploaded_file($ _ FILES ['photo1'] ['tmp_name'],$ img)); {
if(move_uploaded_file($ _ FILES ['photo2'] ['tmp_name' ],$ tmb)); {
{

mysql_query(INSERT INTO`portweb`(`imagename`,`content`,`links`,`photo1`,`photo2`)) VALUES('$ imagename','$ content','$ links','$ pic1','$ pic2'));
回显文件上传成功;
}
}
}
/ * else
{
echo上传失败;
} * /

}

?>

< html>
< head>
< title>上传图片投资组合网络< / title>
< / head>
< body>
< a href =portweb.php>返回< / a>
< br />
< form action =addportweb.phpmethod =postenctype =multipart / form-data>
< label>主图片:< / label>
< input type =filename =photo1/>< br />
< label> Thumb:< / label>
< input type =filename =photo2/>< br />
< label>名称:< / label> < input type =textname =imagenameclass =text_inputmaxlength =100/>< br />
< label>说明:< / label>
< textarea name =contentstyle =width:300px; height:80px; padding:5px; resize:none; >< / textarea的>
< br />

< label>连结:< / label> < textarea name =linksstyle =width:100px; height:50px; padding:5px; resize:none; >< / textarea>< br />
< input type =submitname =submitvalue =upload/>
< / form>
< / body>
< / html>

这里是帮助输出的函数......还有我的问题:

 函数getportweb(){
$ query = mysql_query(SELECT * FROM portweb)or die(mysql_error());
while($ post = mysql_fetch_assoc($ query)){

echo< img src =。$ post ['photo1']。/>;
回显< br>;

echo< img src =。 $ post ['photo2']。 /> 中;
回显< br>;

echo< p> 。 $ post ['imagename']。 < / P> 中;
回显< br>;
回显< p> 。 $ post ['content']。 < / P> 中;
回显< br>;
回显< p> 。 $ post ['links']。 < / P> 中;
回显< br>;

echo< a href = \deleteportweb.php?id =。$ post ['id']。\>删除< / a>;
echo< a href = \editportweb.php?id =。$ post ['id']。\>编辑< / a>;
回显< br>;
}

}

我想相信这是我的问题

  echo< img src =。$ post ['photo1']。/>; 
回显< br>;

echo< img src =。 $ post ['photo2']。 /> 中;
回显< br>;

但是我什么也没得到......请别人帮忙



  echo'< img src =h2_lin>解决方案

'。$ post ['photo1']。'/>';


so am created a form that takes two file buttons (for images) one for the thumbnail and the other for the main image and it has successfully taken the files and placed it in the database, it has also gotten their correct directory...but i have a problem...when it time to echo the images they dont show up...some please help me

here is the form and the code(all in the same file called addimage.php):

<?php
include'includes/connect.php';

if($_POST['submit'])
 {
$img="main/";
$img= $img . basename($_FILES['photo1']['name']);

$tmb="thumb/";
$tmb= $tmb . basename($_FILES['photo2']['name']);


$imagename = mysql_real_escape_string($_POST['imagename']);
$content = mysql_real_escape_string($_POST['content']);
$links = mysql_real_escape_string($_POST['links']);
$pic1 = "main/" .(mysql_real_escape_string($_FILES['photo1']['name']));
$pic2 = "thumb/" .(mysql_real_escape_string($_FILES['photo2']['name']));

if(move_uploaded_file($_FILES['photo1']['tmp_name'], $img));{
    if(move_uploaded_file($_FILES['photo2']['tmp_name'], $tmb));{
{

    mysql_query("INSERT INTO `portweb` ( `imagename`, `content`, `links`, `photo1`, `photo2`)  VALUES('$imagename', '$content', '$links', '$pic1', '$pic2')");
    echo "files upload success";
}
}
}
/*else
{
    echo "upload failed";   
}*/

}

?>

<html>
<head>
<title>upload pictures portfolio web</title>
</head>
<body>
<a href="portweb.php">Back</a>
 <br />
 <form action="addportweb.php" method="post" enctype="multipart/form-data">
 <label>Main Image:</label>
 <input type="file" name="photo1" /><br />
<label>Thumb:</label>
<input type="file" name="photo2" /><br />
<label>Name:</label> <input type="text" name="imagename" class="text_input" maxlength="100" /><br />
<label>Description:</label>
<textarea name="content" style="width: 300px; height:80px; padding: 5px; resize:none;" ></textarea>
<br />

<label>Link:</label> <textarea name="links" style="width: 100px; height:50px; padding: 5px; resize:none;" ></textarea><br />
<input type="submit" name="submit" value="upload" /> 
</form>
</body>
</html>

and here is the function to help with the output...and also my problem:

function getportweb() {
     $query = mysql_query("SELECT * FROM portweb") or die(mysql_error());
      while($post = mysql_fetch_assoc($query)){

        echo "<img src =".$post['photo1']."/>";
            echo "<br>";

        echo "<img src =" . $post['photo2'] . "/>";
            echo"<br>";

        echo "<p>" . $post['imagename'] . "</p>";
            echo "<br>";
        echo "<p>" . $post['content'] . "</p>";
        echo "<br>";
        echo "<p>" . $post['links'] . "</p>";
            echo "<br>";

        echo "<a href=\"deleteportweb.php?id=" . $post['id'] . "\">Delete</a>";
        echo "<a href=\"editportweb.php?id=" . $post['id'] . "\">Edit</a>";
         echo "<br>";
         } 

}

i want to believe this is my problem

echo "<img src =".$post['photo1']."/>";
                echo "<br>";

            echo "<img src =" . $post['photo2'] . "/>";
                echo"<br>";

but i got nothing...please someone help

解决方案

Try something like this:

echo'<img src="'.$post['photo1'].'" />';    

这篇关于我的数据库中的图像不在我的网站上发布(PHP MySQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆