PHP在数据库中插入图片上传网址[关闭]
I have two way for insert image upload url in MySQL database:
One:(only filename)
1410468094_shutterstock_130757219.jpg
Two:(full url)
http://localhost/nws/uploads/files/1/shutterstock_130757219.jpg
which way is better?
我有两种方法可以在MySQL数据库中插入图像上传网址: p>
一:(仅文件名) p>
二:(完整网址) p>
哪种方式更好? p>
div> 1410468094_shutterstock_130757219.jpg code> p>
http://localhost/nws/uploads/files/1/shutterstock_130757219.jpg code> p>
file name is best cause if anytime you change folder name or location .
Second way without the domain name is batter. I mean uploads/files/1/shutterstock_130757219.jpg
is batter. Because your domain name may change over time. But you should put the file path relative to your web root directory.
If all images will be put in the same folder you would like to leave out the path, that way you could move the images one day to S3, CDN or anywhere else and won't have to update all the records. However if the images comes from all over the Internet, you need the full path.