Forum Moderators: coopster
I can upload files to a directory, that bit is OK.
What I want to do is upload an image and store it in a file (ie /images), then store the the lacation in the Database.
I have set up a DB with a filed called image and type of BLOB, not sure how I get the storage inforamtion into this field.
So how do i store ./images/picture1.jpg in the BLOB filed in the DB, so that it can be retreived and allow the image to display if theuser searches the DB
Many thanks
CLive JOy
Yes I only want to store the image path in the DB
So how do i get this path into the DB field from the input form that he user will fill out after using the 'browse' funtion in on of the form fileds to location the image for upload.
I think I somehow need to capture this variable that takes the source location on the USers PC and stores it in the image folder on the server.
So if it is for example mypicture.jpg that the user uploads and this is stored in ./images/mypicture.jpg on the server, how do i get ./images/mypicture.jpg into the correct db field.
I hope that explains my problem
regards
clive
in my opinion you started with the end. first of all, to clear things out, if you're using a form with a file-browse-button on it, the user of the form is not submitting a path to you, she/he is submitting a complete file to your server. detailed information about this is described step by step in the php docs:
Chapter 38. Handling file uploads [de2.php.net]
after that operation, the (image-) file is transfered on the server. you then can work with that file, rename and move it to your wished destination for example. after that, you know for shure where the file is placed so you know the path of that file. this path you can store into your database.
i know there is not one line code in my answer for you, but in my opinion you should get things more clear first so you know how you can solve your problem.
loading an img in your DB using BLOB is not the best way to do it, with hundreds of img you will load tons of data
better way: Load the image path
varchar should be OK, limit to 250 should be more than enough for the path length
You may often search our library
for ex:
Here is your answer [webmasterworld.com]
(look by end of the thread)
regards
henry
I am having a look at the link now.
I will come back with more questions, that is for sure.
So briefly then this is what happens:
1. User uploads a file to the server (ie./images/picture1.jpg)
I am still confused on how I get /images/picture1.jpg path into the db field.
Sorry for being thick here, but as you can gather this is new to me.
All I have done so far is to USE PHP via dreamweaver and I have NEVER hand coded anything.
Regards (with headaches!)
clive