We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Randomize uploaded file names [Answered] | Forum

Greg
Greg Jan 5 '14
Is there a way to randomize the file names of uploaded images much like facebook does so that a savvy non user could not sit and look at all the uploaded photos by just changing the number in the /attach_3.jpg  to /attach_4.jpg ect. ? The photos already get renamed, can I make it random and like 8 or more characters. This would make it very hard for a non user following a direct link to be able to find another photo by trying to guess the number.

Example of facebook image url  https://fbcdn-sphotos-b-a.akamaihd.net/...951_1174947642_n.jpg

The reason I want to do this is to keep the uploaded photos as secure as possible on the site. if there is another way of doing it please let me know that as well.

Thanks for your help.
The Forum post is edited by Alia Apr 10 '14
ross Team
ross Jan 5 '14
Topic was moved from General Questions.
Arash
Arash Feb 26 '14
Would you like to have a function that gives each a timestamp and maybe add another character?


Maybe something like img_[timestamp]_[firstletterofusername].jpg? This is probably doeble.



S. Bourdon
S. Bourdon Feb 27 '14
Here's what I did to fix this issue: http://www.oxwall.org/forum/topic/15786


Hope this helps!

Greg
Greg Feb 27 '14
Thank you guys I think this is what I am looking for. Just so people cant scroll though photos. Now to get my new site working .... cant seem to get 1.6 to work.
Arash
Arash Feb 28 '14
Good that that's soleved!
Daisy Team
Daisy Mar 13 '14
Greg, this problem has been solved for the Photos plugin in 1.6.0 version. However the changes will be applied to the new uploaded photos only in case you've updated your site from 1.5.3 to 1.6.0.

As far as I've understood you are talking about the images uploaded via Newsfeed. If so, you can make changes which S. Bourdon suggested, this solution should solve the problem with newsfeed attachments.
Greg
Greg Apr 5 '14
I went to make these changes but in the new version the file S. Bourdon mentioned is different. Did this move somewhere else or is there a different fix to use in 1.6.0? Thank you

Alia Team
Alia Apr 9 '14
In 1.6, code was moved to ow_system_plugins/base/bol/attachment_service.php:

 $attachDto = new BOL_Attachment();
...
        $fileName = 'attach_' . $attachDto->getId() . '.' . UTIL_File::getExtension($_FILES['attachment']['name']);
        $attachDto->setFileName($fileName);
...
Greg
Greg Apr 9 '14
Thank you Aliia found it and made the changes and it works :)
Alia Team
Alia Apr 10 '14
You are welcome =)_

Marking this topic as [Answered]