所以我创建了一个表单,它带有两个文件按钮(用于图像),一个用于缩略图,另一个用于主图像,它已成功获取文件并将其放入数据库,它还获得了正确的目录。 ..但我有一个问题...当它回应他们没有出现的图像时...有些请帮助我
这里是表单和代码(都在同一个文件中,名为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>
这是帮助输出的功能......还有我的问题:
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>";
}
}
我想相信这是我的问题
echo "<img src =".$post['photo1']."/>";
echo "<br>";
echo "<img src =" . $post['photo2'] . "/>";
echo"<br>";
但我一无所获......请有人帮忙
答案 0 :(得分:-1)
尝试这样的事情:
echo'<img src="'.$post['photo1'].'" />';