in my project i store images(uploaded by user) in a folder, for each respective product.
For example to add a product a form is displayed to user. User fills details about product and selects some images from his computer(5 or more pictures). When submitted i will store product details in a table called Products
. For images uploaded, i create a folder like this: http://mysite.com/uploads/123/
here 123
is product id of product that is newly added. And all images are saved inside it.
Questions:
how to keep track of images uploaded(or filenames of it) for later displaying? that is, when a new product is added, my script will create a fancy uri text. Eg:
http://mysite.com/this-is-my-new-product
. So if user visits this link, it should show all images belonging to that product. For this, I have to keep a separate table with product ids and the filenames ? And query this table and echo filenames from it? Or is it good to scan the folder(example:http://mysite.com/uploads/123/*.jpg
) and echo images one by one, ie. without using a separate table ?is it ok if use the fancy uri for the filenames of images? Example:
/uploads/123/this-is-my-new-product1.jpg
,/uploads/123/this-is-my-new-product2.jpg
,/uploads/123/this-is-my-new-product3.jpg
, etc. ? So, users will see path of first image ashttp://mysite.com/uploads/123/this-is-my-new-product1.jpg
. This is physical address. Will it help in SEO ? Or it is bad practice ? If this is good, then to list all images i should use scanddir() ?
Please guide me through correct path. Thanku