横幅编辑器 - 图片的不同路径

时间:2014-05-26 07:21:09

标签: php mysql upload photo

我必须做一个学校项目,我有点迷失。我必须制作一个横幅编辑器,现在我刚刚制作了要上传的图片的代码,文本,浏览和图片的链接表单。我想要有4个横幅,我不知道如何制作4个不同的路径,所以我可以选择放置所选图片的位置。有人可以给我一个想法或只是指导我吗? 非常感谢你

jooj.php

<form method="post" action="addphoto.php" enctype="multipart/form-data">

<p>
  Photo:
</p>
<input type="hidden" name="size" value="350000">
<input type="file" name="photo"> 
<p>
 Your text:
</p>

</p>
<textarea rows="10" cols="50" name="text">
</textarea>

<p>
  Link:
</p>
<input type="text" name="link" size=50 />
<br/>
<br/>
<input TYPE="submit" name="upload" title="Add data to the Database" value="Submit"/>
</form>

addphoto.php

 <?php


$target = "images1/";
$target = $target . basename( $_FILES['photo']['name']);


$name=$_POST['text'];
$pic=($_FILES['photo']['name']);
$about=$_POST['link'];



if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{

echo "Picture ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory";
}
else {


echo "Sorry, there was a problem uploading your file.";
}

$conn = mysql_connect("localhost", "root", "") or die(mysql_error()) ; 
mysql_select_db("test") or die(mysql_error()); 

$sql = "INSERT INTO employees (text, photo, link) VALUES ('$name', '$pic', '$about')";
mysql_query($sql, $conn);

 $rs = mysql_query("SELECT text,photo FROM employees", $conn);

 echo "<TABLE>";
 while ($row = mysql_fetch_array($rs))
 {
    echo "<TR><TD>".$row["text"]."</TD><TD><IMG SRC='http://localhost/upload/images/".$row["photo"]."' WIDTH='100' ALT='photo'></TD></TR>";
 }
 echo "</TABLE>";

?>

<A HREF="jooj.php">Go back</A>

0 个答案:

没有答案