Uploaded file paths - why so complex?
Permalink
Hello all
I'm wondering why the paths to file uploads are so complex. I've got this for example:
http://www.website.com/c5/files/2412/7116/0488/photo.jpg...
Why the /2412/7116/0488/? Is it possible to strip this down so things are simply stored in files/? I ask because my site will have a lot of PDF downloads, and it looks 'cleaner' if they come from site.com/files/doc.pdf. I get the impression that setting an alternative location for saves will just change files/, but not the nested numbered directories that are created below it.
If there's a good reason for this I'd be interested to hear it anyway (it's always good to learn why certain decisions are made) :)
I'm wondering why the paths to file uploads are so complex. I've got this for example:
http://www.website.com/c5/files/2412/7116/0488/photo.jpg...
Why the /2412/7116/0488/? Is it possible to strip this down so things are simply stored in files/? I ask because my site will have a lot of PDF downloads, and it looks 'cleaner' if they come from site.com/files/doc.pdf. I get the impression that setting an alternative location for saves will just change files/, but not the nested numbered directories that are created below it.
If there's a good reason for this I'd be interested to hear it anyway (it's always good to learn why certain decisions are made) :)
Just a guess... but I think it might have something to do with the versioning for files. Everything in the File Manager has version histories just like pages - you can restore previous versions / replace /etc.
It's also a security measure. You can use the API to access these quite easily to where from a programming standpoint, it's moot.
And if it's just for extras on templates...I just create a folder in the root called "images", src that and call it a day.
an example of how to grab any file by ID from your controller.
And if it's just for extras on templates...I just create a folder in the root called "images", src that and call it a day.
an example of how to grab any file by ID from your controller.
function getThumbnail($ID) { $f = File::getByID($ID); $fullPath = $f->getPath(); $relPath = $f->getRelativePath(); return $relPath ; }
Thanks for that.
I notice that on a live site file links are actually like this:
http://www.website.com/index.php/download_file/view/13/...
...which is a lot cleaner. I presume this ties in with download stats, too.
I notice that on a live site file links are actually like this:
http://www.website.com/index.php/download_file/view/13/...
...which is a lot cleaner. I presume this ties in with download stats, too.