textbox Posted April 24, 2007 Share Posted April 24, 2007 Hello there, i wish to create an upload system for my new users to use on my community site. I want the images to be uploaded to a db, and the db to tell me which user uploaded which image, so i can filter the images out on their profile page. I would also like to be able to allow them to set a default image. Any help would be great! Link to comment https://forums.phpfreaks.com/topic/48508-image-upload/ Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 how far you got so far ? basically theirs 2 main steps 1 upload image 2 store path to image in database Link to comment https://forums.phpfreaks.com/topic/48508-image-upload/#findComment-237371 Share on other sites More sharing options...
textbox Posted April 24, 2007 Author Share Posted April 24, 2007 I have this so far; <?php $cn = mysql_connect("localhost","dbuser","pwd"); mysql_select_db("db",$cn); if ($act=='view'){ $sql="SELECT * FROM tbl_image where id=$id"; $rst=mysql_query($sql) or die('gagal'); $data=mysql_fetch_array($rst); $type=$data[type]; Header("Content-type: $type"); echo $data[image]; } if ($act=='del'){ $sql="DELETE FROM tbl_image where id=$id"; $rst=mysql_query($sql) or die('gagal'); } if($submit) { $type = $_FILES['file']['type']; copy ($_FILES['file']['tmp_name'], "tmp/tmp.jpg") or die ("Could not copy"); $filer="tmp/tmp.jpg"; $handle = fopen($filer, "r"); $pure = addslashes(fread($handle, filesize($filer))); $sql = "insert into tbl_image(image,type) values('$pure','$type')"; $result = mysql_query($sql,$cn)or die(mysql_error()); } $sql="SELECT * FROM tbl_image"; $rst=mysql_query($sql) or die('gagal'); while ($data=mysql_fetch_array($rst)){ $id=$data[id]; echo "picture no $id <a href='./image.php?act=del&id=$id'>delete</a><br><img src='./image.php?act=view&id=$id'><br><br>"; } ?> So i want to be able to make the table have my username's value in it. And, how do i pull the files out?! Thanks Nick Link to comment https://forums.phpfreaks.com/topic/48508-image-upload/#findComment-237444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.