Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SecureFiles - Original Document Filename Possible?

Go to End

3 Posts   1473 Views


Community Member, 45 Posts

14 June 2010 at 3:42am

Edited: 14/06/2010 3:44am

when using this module - I have noticed that the downloaded filename contains the full path of the file (backslashes within the path are replaced with underscores) - instead of just the original document filename. is there anyway to configure this to just be the original filename?

here is an example:

original filename (as displayed in the Files & Images section):

when downloading generated link from front-end website (i am using $File.URL to specify the target href within a link tag):

when viewing the source code, the link path is to the original filename - but when browser pops up the file (and asks to View or Save As), this very long filename is displayed.

thanks for any help on this and thank you for such an excellent module!


Community Member, 45 Posts

15 June 2010 at 1:33pm

not sure what this means, but just tested across IE8, firefox and chrome.

1. chrome downloads the file according to the correct original filename.
2. firefox and IE8 both download with the very long filename (that includes the full path in the filename)

anybody have any clue as to why this happens?


Community Member, 45 Posts

15 June 2010 at 2:02pm

Edited: 15/06/2010 2:03pm

Hamish -

I figured out a quick fix but required me to update the core module. this probably needs to be added so the filenames are downloaded properly.

Line 158

$mimeType = HTTP::getMimeType($file_name);
header("Content-Type: {$mimeType}; name=\"" . basename(addslashes($file_name)) . "\"");
header("Content-Disposition: attachment; filename=" . basename(addslashes($file_name)));
header("Content-Length: {$file_size}");
header("Pragma: ");

Adding basename function seemed to correct the issue.