Im creating a Yii app where i will save images into the database. Now im searching a php or yii function that make this image file name clean so i can use later in my urls.
For example if i upload:
test image.jpg
testímage.jpg
tést ímage.jpg
in my database i can save them as test-image.jpg or just testimage.jpg
Which other methods do you use? You use real names or just time stamps ? Which you think is the method to go to avoid duplicates?
Thanks
Personally I would keep the original filename. If you need something unique, you could add a hash or the id of the row at the end. I know that’s just for the last 10% percent maybe, but if the filename represents what’s shown in the picture, you can gain in SEO.
To make your filename “clean”, you can use functions like this (PHP):