file_helper: read_file issues with filename including brackets |
[eluser]RBrowne[/eluser]
I've been trying to use the read_file function of file_helper, which works for the most part. However whenever there is a ( in the filename, the function fails to be able to read the function. I've checked the allowed chars in the url - not that. Checked the file exists - it does. Tried urlencode/decode/recode and they don't help. Here's my function for the downloader: Code: function index() { Does anyone have any ideas? I don't really want to write a function to strip the brackets out of the naming function, as this would be a pain. Any help would be greatly appreciated. Rich
[eluser]Dam1an[/eluser]
The file reading is actually taken care of by the PHP method file_get_contents so the error is likely to come about there... The way I always handle files is: 1) When a file is added, give it a unique name made up of letters, numbers and underscores (all safe characters) 2) Add a row in the database which maps the original file name to the one on disk 3) When there is a request for the file (either by the real name or the name on disk) find its location in the database table and pass that into the force_download helper
[eluser]TheFuzzy0ne[/eluser]
Try escaping the bracket with a double-backslash. You'll probably need to do that with spaces and other special characters ("'\-) and so on. |
Welcome Guest, Not a member yet? Register Sign In |