ingeva Posted October 10, 2007 Share Posted October 10, 2007 I've made a special page for only downloading files. This is a private, protected page, so I can't give a link to it. The problem is that some filenames contain non-latin characters which are stripped off, so the user doesn't get the complete name. Spaces are converted to underscores, but we can live with that. When characters disappear, it's another matter. My download script can be seen here: http://www.elouai.com/force-download.php Any better ideas? Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 10, 2007 Share Posted October 10, 2007 you can't do anything about latin characters unless you run trans on the file name before showing it.also latin characters will only work if IE allows the characters to be shown. WHat SHOULD happen is that all latin characters be turned to standard ascii characters, but you would sue TRANS() for this. Hope that helps. Quote Link to comment Share on other sites More sharing options...
ingeva Posted October 11, 2007 Author Share Posted October 11, 2007 you can't do anything about latin characters unless you run trans on the file name before showing it.also latin characters will only work if IE allows the characters to be shown. WHat SHOULD happen is that all latin characters be turned to standard ascii characters, but you would sue TRANS() for this. Hope that helps. Sorry, the characters are within the ISO-8859-1 character set, but the rawurlencode function still doesn't recognize all of them. They are used in filenames both in my Windows PC and on my Linux host. (If I do this from my own local server this problem doesn't exist!) I find no trans function in the php manual. In my php script I find all the files and display them with the URL set like this: http://domain.com/force.php?file=<filename> . I've translated the filename using rawurlencode, and then replaced some upper-case characters (that are not caught by it) with str_replace: $from = array ("Æ","Ø","Å","Ä","Ö"); $to = array ("%C6","%D8","%C5","%C4","%D6"); $urlname = str_replace ($from, $to, $urlname); All characters are 8 bits. Using UTF-8 doesn't help. The file displays perfectly file if I use its URL without translation. If I use ftp the file is transmitted with the original filename, even with the spaces intact. Example of how the filename is translated by the download routine: Noter/Å, æ kjinne ein kar.pdf => Noter/,æ_kjinne_ein_kar.pdf Are we closer to a solution? Can I call ftp instead to have the file downloaded correctly? We must assume that all users are computer novices; i.e. not even righ-click/menu is acceptable here. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 13, 2007 Share Posted October 13, 2007 you cuold always have the links redirect as follows: "ftp://user:pass@ftp.com/path/to/files/file name§♪/[◄♀ΩV65♦.pdf" as long as things are in brackets, spaces won't be changed to _ or %20. Quote Link to comment Share on other sites More sharing options...
ingeva Posted October 13, 2007 Author Share Posted October 13, 2007 I can't make that work. The filename is not recognized but it's correct and in the right folder. If I open ftp with the folder I can manipulate it normally, but I don't like to use that on the website. Also, I do not want to have username and password displayed in the addres line. Could you please give me a short coding example? Thanks! Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 13, 2007 Share Posted October 13, 2007 hmm as far as ""ftp://user:pass@ftp.com/path/to/files/file name§♪/[◄♀ΩV65♦.pdf"" goes, you dont want the user and pass, you could always do a javascript to hide hte user/pass: //THIS CODE IS GO.PHP: <?PHP header('location = "ftp://user:pass@ftp.com/path/to/files/'.$file.'";'); ?> //CODE FOR BLA.PHP <?PHP //stuff in php ?> <!-- HTML STUFF --!> <a href="go.php?FILE">FILE</a> <!-- HTML STUFF --!> <?PHP //stuff in php ?> Quote Link to comment Share on other sites More sharing options...
ingeva Posted October 14, 2007 Author Share Posted October 14, 2007 OK, thanks. I have something to work with here. Quote Link to comment Share on other sites More sharing options...
ingeva Posted October 16, 2007 Author Share Posted October 16, 2007 Well, now I've tried all the combinations that I could think of. The closest I come is to have the file displayed in a program, like Acrobat Reader for .PDF, or Fax viewer for picture file. That's what I'm trying to avoid. This is for download only. In this case there's no point in displaying the files online. This must be done in a way that computer illiterates can do it. The files should be downloaded, preferably with their original filename, and presenting a choice of location for the user. The function I'm using does this task nicely, but it changes the filenames. I was hoping it would be possible to avoid that. Quote Link to comment Share on other sites More sharing options...
ingeva Posted October 26, 2007 Author Share Posted October 26, 2007 Evidently this is not a php problem. By accident I tested my code with FireFox, and it had no problem. The're probably not a single FF user in my community, so having them change because of this is not a solution. Until someone comes up with a better idea, or Microsoft does something with their software, we'll probably have to live with it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.