grlayouts Posted June 22, 2007 Share Posted June 22, 2007 i have an upload script that uploads the file fine. however it will not add the image to the database. i have placed the bit of code below, any ideas? { move_uploaded_file($_FILES["file"]["tmp_name"], 'uploads/'. $_FILES["file"]["name"] .''); echo "Stored in: " . "uploads/" . $_FILES["file"]["name"]; print '<p>'.$type.'</p>'; mysql_query("insert into images (user, image) values('$stat[id]','. $_FILES["file"]["name"] .')") or die("Could not update database."); } Quote Link to comment Share on other sites More sharing options...
grlayouts Posted June 23, 2007 Author Share Posted June 23, 2007 ne1? Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 23, 2007 Share Posted June 23, 2007 Its not a good idea to store images in db.Store a link to image in db. What specific error u getting. Quote Link to comment Share on other sites More sharing options...
grlayouts Posted June 23, 2007 Author Share Posted June 23, 2007 none. it is the link i want to save in the database?? but the image uploads fine. just not the database part? Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 23, 2007 Share Posted June 23, 2007 It mean u want to store a link in db for that picture. So assign ur file name to a variable and then put in ur query to store. Quote Link to comment Share on other sites More sharing options...
grlayouts Posted June 23, 2007 Author Share Posted June 23, 2007 why would i need to assign when i can use images/uploads/$Files[name].$files[extension] ?? Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 23, 2007 Share Posted June 23, 2007 i mean assign it like this its easy to handle code. $fileName = $_FILES['filename']['name']; Than insert it like this: $query = "INSERT INTO upload (name)VALUES ('$fileName')"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.