Reputation: 31
I am sort of a newbie with MySQL. I have a website that will retrieve and allow user to upload photos to the website. I am going to store the photos as a file system inside a folder call \users\images
. How would I call the photos from the MySQL using file system? I know people talk about index which make sense but not sure how to code it. If someone has an example or provide me a solution to store photos using file system and display it on the web for each user login to my website.
Upvotes: 2
Views: 2756
Reputation: 8741
Save the image files in \users\images location and save path with filename in mysql table.
The datatype needed would be one that accepts strings, such as VARCHAR
for example.
Here is a reference to other types:
Upvotes: 3
Reputation: 56769
You will have to link it all together yourself. Just think through it step-by-step:
picture.jpg
.\users\%username%\picture.jpg
pictures
.Then if you wanted to display the photos to a user.
displayphotos.php
).pictures
table where userid=
current user logged in.<img
tag pointing to the path of the picture file<img
tags in some sort of table layout, maybe 4-columns wide.There isn't some sort of out-of-the-box concept in MySQL that automatically manages filenames that you store in a database pointing to physical files.
Upvotes: 1
Reputation: 167172
Do this way. Upload the images in \users\images\
. Have an index in the MySQL Server database with the path too.
+----+---------------------+
| id | path |
+----+---------------------+
| 1 | \users\images\1.png |
| 2 | \users\images\2.png |
| 3 | \users\images\3.png |
| 4 | \users\images\4.png |
+----+---------------------+
Upvotes: 0