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.

All other Modules /

Discuss all other Modules here.

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

SecureFiles - Original Document Filename Possible?


Reply


3 Posts   1144 Views

Avatar
bmc38119

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):
1-Premium-Lenses-Cover-Sheet.doc

when downloading generated link from front-end website (i am using $File.URL to specify the target href within a link tag):
assets_Uploads_secure-files_Premium-Lenses_1-Premium-Lenses-Cover-Sheet.doc

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!

Avatar
bmc38119

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?

Avatar
bmc38119

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.

SecureFileController.php
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: ");
[\code]

Adding basename function seemed to correct the issue.