Jump to content

[SOLVED] Characters stripped when downloading


ingeva

Recommended Posts

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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

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

?>

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

  • 2 weeks later...

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.