Forum Moderators: coopster

Message Too Old, No Replies

Storing file path in database

         

kkonline

8:19 am on Sep 15, 2007 (gmt 0)

10+ Year Member



I want to do the following

Just upload images/videos as normal upload, and store the path to the file in the database. Have a field for views, rating, etc. Then on the script that displays the image or video, mysql_query() to update the database.

How to go about each step, is there any tutorial for doing do or please suggest some sample code to do the above. My main concern is how to store the path of the file in database and how to retrieve the file. Means first take the id then query the database get the path and then display it?

d40sithui

12:27 pm on Sep 17, 2007 (gmt 0)

10+ Year Member



kkonline,
you will need 2 tables for this operation. the 2nd table is needed only if you want the rating system.

image_table{
image_id int auto_increment primary key,
image_url text,
image_views int,
date_submitted date,
image_catergory int,
etc...
}

rating_table{
image_id int,
rate_value int,
user varchar(50),
...
}

for uploading and storing files, you will wnt to play with $_FILES, is_uploaded_file(), move_uploaded_file().
[us.php.net...]
[us.php.net...]

dont forget to check for file type!

jatar_k

1:14 pm on Sep 17, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



this tutorial might help
[php.net...]

>> Means first take the id then query the database get the path and then display it?

pretty much

you need to decide before hand how and where you are going to store the file, then it is just a matter of getting the filename and the path will already be known