Error downloading a file with accents. :s

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mirux
Forum Commoner
Posts: 29
Joined: Sun May 13, 2007 7:11 pm

Error downloading a file with accents. :s

Post by Mirux »

Check this: http://www.codersphp.com/mirux/DHH/inde ... =ebiblicos

Try to download "Sin Autor - No es fácil" or any file that has áéíóúñ in author's name or title's name. And you'll get that error.

This is the part of the code:

Code: Select all

echo "<a class='ico' href='./files/".$msg->author. " - ". $msg->title. ".doc"."'><center><img src='./images/doc.gif'></center></a>";
Any idea how to solve this? I am avoiding to rename the files to someone like 01.doc, etc.. Because I need them with its right name.

By the way, special characters I solved them with htmlentities();
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

You'll have to remove the special characters from the filenames, or url-encode the links to them.
Mirux
Forum Commoner
Posts: 29
Joined: Sun May 13, 2007 7:11 pm

Post by Mirux »

How is that url enconding thingy? I've tryed that before but it doesn't seem to work.

Where should I add it?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Pass your filenames through urlencode()
Mirux
Forum Commoner
Posts: 29
Joined: Sun May 13, 2007 7:11 pm

Post by Mirux »

Well, actually I fixed it with a simple header.

I inserted this line:

Code: Select all

header("Content-Type: text/html;charset=ISO-8859-1");
Maybe it is not a proper way to fix this but it works. I don't see any other good solution.

If anyone knows a better one, let me know.

Thanks guys for the support.
Post Reply