PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Uploading files with speical characters....
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Uploading files with speical characters....

Réponse
 
LinkBack Outils de la discussion
Vieux 17/06/2008, 09h20   #1
jodleren
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Uploading files with speical characters....

Hi

I work on s system, which is based on one.com (Denmark) - and used
elsewhere, in my case in the baltics.
When uploading files, there is problem with Lativian characters - the
e with overscore (e with a line above; ē )

The problem is, that when uploading, it changes the "e" to the html
code:

echo "\r\n10- ".$_FILES["newfile_$i"]['name']."<br>";
result:
whatever_ē.pdf

Even those do not :
echo "\r\n11- ".html_entity_decode($_FILES["newfile_$i"]
['name'])."<br>";
echo "\r\n12- ".stripslashes($_FILES["newfile_$i"]['name'])."<br>";

The file header reads:
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1">

My problem - the system is in use in quite some places, to I cannot
rule any characters out.... (there are Danish, Swedish, Norweigian,
Estonia and German files in the system - basically Baltic,
Scandinavian and wharver charset they are using in Germany) . The best
I can think of now is entity decode, and the replace all other &#__;
which underscore or something....

Any ideas anyone?
  Réponse avec citation
Vieux 17/06/2008, 09h53   #2
Dikkie Dik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Uploading files with speical characters....

> I work on s system, which is based on one.com (Denmark) - and used
> elsewhere, in my case in the baltics.
> When uploading files, there is problem with Lativian characters - the
> e with overscore (e with a line above; ē )
>
> The problem is, that when uploading, it changes the "e" to the html
> code:
>
> echo "\r\n10- ".$_FILES["newfile_$i"]['name']."<br>";
> result:
> whatever_ē.pdf


<snip>

>
> The file header reads:
> <meta http-equiv="content-type" content="text/html;
> charset=iso-8859-1">
>
> My problem - the system is in use in quite some places, to I cannot
> rule any characters out.... (there are Danish, Swedish, Norweigian,
> Estonia and German files in the system - basically Baltic,
> Scandinavian and wharver charset they are using in Germany) . The best
> I can think of now is entity decode, and the replace all other &#__;
> which underscore or something....
>
> Any ideas anyone?


Are you sure that all the necessary characters are in iso-8859-1? For
example, the Euro sign is not. For international sites, I'd use utf-8.
For any character that is not in iso-8859-1, there is little alternative
but to change it into an HTML entity.

A lot depends on your operating system, as you are dealing with file
names. If your OS uses iso-8859-1 file names, you are stuck with it and
can use a whitelist of acceptible characters. The rest can be replaced
by an underscore, for example. This is even a good idea for
non-international sites, as some characters have special meaning on
different operating systems.

Good luck!
  Réponse avec citation
Vieux 17/06/2008, 11h46   #3
Álvaro G. Vicario
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Uploading files with speical characters....

jodleren escribió:
> I work on s system, which is based on one.com (Denmark) - and used
> elsewhere, in my case in the baltics.
> When uploading files, there is problem with Lativian characters - the
> e with overscore (e with a line above; ē )
>
> The problem is, that when uploading, it changes the "e" to the html
> code:
>
> echo "\r\n10- ".$_FILES["newfile_$i"]['name']."<br>";
> result:
> whatever_ē.pdf


I haven't found the PHP manual page where such feature is documented but
a few tests have shown that this behaviour changes depending on the
charset parameter of the "Content-Type" HTTP header; even if I don't set
an actual HTTP header and I just use a <meta> tag:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

With a packet sniffer I've determined that it's not the browser who
changes it. If you write into a file the entities are still there, so it
doesn't seem to be an Apache feature. It's really weird.

If it's not feasible to change your encoding to UTF-8, well, I don't
know what you can do...


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
  Réponse avec citation
Vieux 17/06/2008, 15h31   #4
matech
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Uploading files with speical characters....

On 17 Jun, 11:46, "Álvaro G. Vicario"
<alvaroNOSPAMTHA...@demogracia.com> wrote:
> jodleren escribió:
>
> > I work on s system, which is based on one.com (Denmark) - and used
> > elsewhere, in my case in the baltics.
> > When uploading files, there is problem with Lativian characters - the
> > e with overscore (e with a line above; ē )

>
> > The problem is, that when uploading, it changes the "e" to the html
> > code:

>
> > echo "\r\n10- ".$_FILES["newfile_$i"]['name']."<br>";
> > result:
> > whatever_ē.pdf

>
> I haven't found the PHP manual page where such feature is documented but
> a few tests have shown that this behaviour changes depending on the
> charset parameter of the "Content-Type" HTTP header; even if I don't set
> an actual HTTP header and I just use a <meta> tag:
>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>
> With a packet sniffer I've determined that it's not the browser who
> changes it. If you write into a file the entities are still there, so it
> doesn't seem to be an Apache feature. It's really weird.
>
> If it's not feasible to change your encoding to UTF-8, well, I don't
> know what you can do...
>
> --
> --http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
> -- Mi sitio sobre programación web:http://bits.demogracia.com
> -- Mi web de humor al baño María:http://www.demogracia.com
> --


I have the same problem but with uploading excel files to mysql 5. It
doesn't matter if I use UTF-8 or iso-8859-1 and uploading the
trademark symbol. htmlspecialchars() or htmletities() doesn't ?
  Réponse avec citation
Vieux 18/06/2008, 10h01   #5
jodleren
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Uploading files with speical characters....

On Jun 17, 5:31Âpm, matech <robert.mat...@hotmail.co.uk> wrote:
> On 17 Jun, 11:46, "Ãlvaro G. Vicario"
>
>
>
>
>
> <alvaroNOSPAMTHA...@demogracia.com> wrote:
> > jodleren escribió:

>
> > > I work on s system, which is based on one.com (Denmark) - and used
> > > elsewhere, in my case in the baltics.
> > > When uploading files, there is problem with Lativian characters - the
> > > e with overscore (e with a line above; Ä“ )

>
> > > The problem is, that when uploading, it changes the "e" to the html
> > > code:

>
> > > echo "\r\n10- ".$_FILES["newfile_$i"]['name']."<br>";
> > > result:
> > > whatever_Ä“.pdf

>
> > I haven't found the PHP manual page where such feature is documented but
> > a few tests have shown that this behaviour changes depending on the
> > charset parameter of the "Content-Type" HTTP header; even if I don't set
> > an actual HTTP header and I just use a <meta> tag:

>
> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

>
> > With a packet sniffer I've determined that it's not the browser who
> > changes it. If you write into a file the entities are still there, so it
> > doesn't seem to be an Apache feature. It's really weird.

>
> > If it's not feasible to change your encoding to UTF-8, well, I don't
> > know what you can do...

>
> > --
> > --http://alvaro.es-Ãlvaro G. Vicario - Burgos, Spain
> > -- Mi sitio sobre programación web:http://bits.demogracia.com
> > -- Mi web de humor al baño MarÃa:http://www.demogracia.com
> > --

>
> I have the same problem but with uploading excel files to mysql 5. It
> doesn't matter if I use UTF-8 or iso-8859-1 and uploading the
> trademark symbol. htmlspecialchars() or htmletities() doesn't ?- Hidequoted text -


I tried some of these, no luck.

I made a replace for known letters ( e.g. ē => e ) end for the
rest I just replace them with _ (underscore)
That way I can avoid any problems.
I am just wondering when they start using russian letters in
filenames... hope they wont

/S
  Réponse avec citation
Vieux 18/06/2008, 19h21   #6
Kristaps Kûlis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Uploading files with speical characters....

On Jun 17, 11:20 am, jodleren <sonn...@hot.ee> wrote:
> Hi
>
> I work on s system, which is based on one.com (Denmark) - and used
> elsewhere, in my case in the baltics.
> When uploading files, there is problem with Lativian characters - the
> e with overscore (e with a line above; ē )
>
> The problem is, that when uploading, it changes the "e" to the html
> code:
>
> echo "\r\n10- ".$_FILES["newfile_$i"]['name']."<br>";
> result:
> whatever_ē.pdf
>
> Even those do not :
> echo "\r\n11- ".html_entity_decode($_FILES["newfile_$i"]
> ['name'])."<br>";
> echo "\r\n12- ".stripslashes($_FILES["newfile_$i"]['name'])."<br>";
>
> The file header reads:
> <meta http-equiv="content-type" content="text/html;
> charset=iso-8859-1">
>
> My problem - the system is in use in quite some places, to I cannot
> rule any characters out.... (there are Danish, Swedish, Norweigian,
> Estonia and German files in the system - basically Baltic,
> Scandinavian and wharver charset they are using in Germany) . The best
> I can think of now is entity decode, and the replace all other &#__;
> which underscore or something....
>
> Any ideas anyone?


You can try iconv on file name, like iconv('UTF-8', 'iso-8859-1//
TRANSLIT', $s);
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h27.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18234 seconds with 14 queries