pcbguy Posted December 3, 2007 Share Posted December 3, 2007 I am trying to upload a picture to the database but save it in a directory. I can't seem to figure out what the problem is with this script. Thanks if you can help. <?php //This is the directory where the images will be saved $target="images/"; $target=$target.basename($_FILES['photo']['name']); //This gets all the other information from the form $position=$_POST['position']; $year=$_POST['year']; $make=$_POST['make']; $model=$_POST['model']; $price=$_POST['price']; $description=$_POST['description']; $picture=($_FILES['picture']['name']); //Connects to Database include "netconnect.php"; //Writes the information to the database mysql_query("INSERT INTO for_sale (position,year,make,model,price,description,picture) VALUES ('$position','$year','$make','$model','$price','$description','$picture')"); //Writes photo to the server if(move_uploaded_file($_FILES['picture']['tmp_name'],$target)) { //Tells you if its all okay echo "The file" .basename($_FILES['uploadedfile']['name']). "has been uploaded, and your information has been added to the directory"; } else{ //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> Quote Link to comment Share on other sites More sharing options...
Daleeburg Posted December 3, 2007 Share Posted December 3, 2007 Ok, your really messing with my head here, Is this solved/fixed, or do you still need help, If it is solved, go to the very bottom and click the "Solved" link. Quote Link to comment Share on other sites More sharing options...
pcbguy Posted December 3, 2007 Author Share Posted December 3, 2007 sorry bout that. 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.