On Oct 26, 2010, at 10:10 AM, Marc Guay wrote:

>> A windows server, or windows client to the same Linux server? I believe that 
>> this issue is starting to get a bit over my head, with the different 
>> operating systems involved and such.
> Windows server.  This is over my head, too.  I'm guessing that Windows
> and Linux encode filenames differently and when I transferred the file
> from one to the other, some kind of adjustment was made.
> Marc

I think one way to do this is something like this (untested):

1.  Put all of your files in some directory on the server.

2.  Change your <a href="http://example.com/encoded-file-name.pdf";>my file</a> 
to <a href="http://example.com/download-file.php?fileID=xxx";>my file</a> where 
xxx is the urlencoded version of "encoded-file-name.pdf".  (xxx could also be a 
fileID number if stored in a database.)

3.  In download-file.php do something like this:

  $parent_directory = "/path/to/parent/directory/"; // can be in or out of web 
  if (file_exists($parent_directory . "encoded-file-name.pdf")) {
    $data = file_get_contents($parent_directory . "encoded-file-name.pdf");
    $file_name_with_french_chars = rawurldecode("encoded-file-name.pdf");

    header("Content-type: application/octet-stream");
    header("Content-disposition: Attachment; 
filename=\"$file_name_with_french_chars\""); // this line assigns the "nice" 
looking name as the file name
    echo $data;
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to