PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hey, i need help storing an image in my database via the URL(image location) at the moment my php code is storing the image in a folder on the directory called upload. here is the code:
<?php
// Where the file is going to be placed
$target_path = "upload
/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$target_path = "upload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
Click <a href="products.php">HERE</a> to go back to form
ok ... what is it exactly that you need help WITH ?
you have shown no database information - table or row structure or even the type of database you are using.
at a minimum, you will want a unique identifier and a filename. Other options could include a image title, description, owner name, etc.
you will need to create a database, a user for the database associated with the right permission to use the database, a table, then the row structure relating to the options mentioned above. Then you would need to construct code to access, write, and read from your db table, which depends on the database used.
There are many db tutorials out there. I would suggest you start with google and start reading.
Then construct your code and feel free to post it if you ahve any problems and e can help you with it.