Jump to:

10848 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » SecureFiles - Original Document Filename Possible?

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1014 Views
  • bmc38119
    Avatar
    Community Member
    45 Posts

    SecureFiles - Original Document Filename Possible? Link to this post

    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!

  • bmc38119
    Avatar
    Community Member
    45 Posts

    Re: SecureFiles - Original Document Filename Possible? Link to this post

    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?

  • bmc38119
    Avatar
    Community Member
    45 Posts

    Re: SecureFiles - Original Document Filename Possible? Link to this post

    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.

    1014 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.