Enregistrer un fichier image avec un nom Grecque...

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Enregistrer un fichier image avec un nom Grecque...

Re: Enregistrer un fichier image avec un nom Grecque...

par stephS » 15 oct. 2015, 09:23

Bonjour à tous,

J'ai aussi réessayé ce bout de code mais les noms des fichiers sont toujours illisibles ??

Code : Tout sélectionner

<?php header( 'content-type: text/html; charset=utf-8' ); echo "V10"; $targetPath="DATA/TempUpload/LBSMaintenanceNePasSupprimer/"; $targetFile=$targetPath . stripslashes("Pour_test.jpg"); echo $targetFile; $chain="χωρις τιτλ"; echo $chain;//Affichage page navigateur : χωρις τιτ copy($targetFile, $targetPath . stripslashes($chain."Original.jpg")); //Fichier enregistré sur le disque avec comme nom : χωρις τιτλOriginal.jpg echo "mb_convert_encoding"; $chain =mb_convert_encoding("χωρις τιτλ", "UTF-8", "Windows-1253"); echo $chain; //Affichage page navigateur : χωρις τιτλ copy($targetFile, $targetPath . stripslashes($chain."Grecque.jpg")); //Fichier enregistré sur le disque avec comme nom : χωρις τιτλGrecque.jpg echo "iconv"; $chain = iconv("UTF-8", "Windows-1253", "χωρις τιτλ"); echo $chain;// ����� ���� copy($targetFile, $targetPath . stripslashes($chain."inconvGrecque.jpg")); //Fichier enregistré sur le disque avec comme nom : ÷ùñéò ôéôëinconvGrecque.jpg ?>

Re: Enregistrer un fichier image avec un nom Grecque...

par stephS » 14 oct. 2015, 17:12

Cela ne fonctionne pas non pas non plus :

//Grecque
//Nous devrions avoir un ficher nommé "χωρις τιτλ Grecque.jpg" et un autre "χωρις τιτλ inconvGrecque.jpg"

Code : Tout sélectionner

$chain =mb_convert_encoding("χωρις τιτλ", "UTF-8", "Windows-1253"); copy($targetFile, $targetPath . stripslashes($chain.".jpg")); //Fichier enregistré sur le disque avec comme nom : χωρις τιτλ Grecque.jpg $chain = iconv("UTF-8", "Windows-1253", "χωρις τιτλ"); copy($targetFile, $targetPath . stripslashes($chain." inconv.jpg")); //Fichier enregistré sur le disque avec comme nom : ÷ùñéò ôéôë inconvGrecque.jpg
Je vais finir par croire que l'enregistrement de fichier avec des noms étrangers est impossible sous php/windows.

Re: Enregistrer un fichier image avec un nom Grecque...

par stephS » 14 oct. 2015, 13:21

J'ai oublié de vous indiquer que en haut du script PHP j'ai bien :
header( 'content-type: text/html; charset=utf-8' );

Par conséquent le serveur renvoie bien des chaines en UTF-8 ?

Enregistrer un fichier image avec un nom Grecque...

par stephS » 14 oct. 2015, 13:15

Bonjour à tous,

Cela fait quelques jours que je bataille avec le codage des caractères en PHP et voici ma problématique :

J'ai un script ci-dessous qui à pour but d'enregistrer un fichier image (.jpg) avec un nom comprenant des caractères Grecques.
Aucun des fichiers créés pour le test n'a le nom que je lui demande une fois enregistré sur le disque du serveur.
Je ne sais plus par quel bout prendre ce problème. Windows n'est pas le système idéal pour l'utilisation de chaines de caractère en langue étrangère et je pourrai me tourner vers un serveur PHP LINUX / Apache (Unicode) mais j'aimerai comprendre ou est mon erreur dans ce code.

Merci d'avance à celui qui pourra me dépanner.
Stéphane


Note : Le serveur est Windows IIs (FastCGI PHP 5.4.24)
Windows NT LBS 6.2 build 9200 (Unknown Windows version Standard Edition) i586

Réglages PHP.ini

iconv :

iconv support enabled
iconv implementation "libiconv"
iconv library version 1.14

Directive Local Value Master Value
iconv.input_encoding UTF-8 UTF-8
iconv.internal_encoding UTF-8 UTF-8
iconv.output_encoding UTF-8 UTF-8


mbstring :
Multibyte Support enabled
Multibyte string engine libmbfl
HTTP input encoding translation enabled
libmbfl version 1.3.2

mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

Multibyte (japanese) regex support enabled
Multibyte regex (oniguruma) version 4.7.1

Directive Local Value Master Value
mbstring.detect_order no value no value
mbstring.encoding_translation On On
mbstring.func_overload 0 0
mbstring.http_input auto auto
mbstring.http_output auto auto
mbstring.http_output_conv_mimetypes ^(text/|application/xhtml\+xml) ^(text/|application/xhtml\+xml)
mbstring.internal_encoding no value no value
mbstring.language neutral neutral
mbstring.strict_detection Off Off
mbstring.substitute_character no value no value




Voici le script PHP en question :

Code : Tout sélectionner

$tab = array("UTF-8", "ASCII", "Windows-1252", "Windows-2312", "Windows-28597","Windows-874", "Windows-932", "Windows-936", "Windows-949", "Windows-950", "Windows-1200", "Windows-1201", "Windows-1250", "Windows-1251", "Windows-1252", "Windows-1253", "Windows-1254", "Windows-1255", "Windows-1256", "Windows-1257", "Windows-1258", "Windows-6500", "Windows-6501", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-10","ISO-8859-11","ISO-8859-12","ISO-8859-13","ISO-8859-14","ISO-8859-15", "CP1256", "CP936", "CP2312", "CP28597", "CP932", "gb2312", "GB2312", "shift_jis", "GB18030", "ibm869", "big5", "utf-32", "utf-32BE", "x-cp20936", "x-cp50227"); $chain = ""; foreach ($tab as $i) { foreach ($tab as $j) { //Avec mb_convert_encoding //setlocale(LC_ALL, "ell" , "greek"); $chain = " $i vers $j "." ".mb_convert_encoding("Λίπη", $i, $j); //Chinois simplifié //$chain = " $i vers $j "." ".mb_convert_encoding("谷", $i, $j); copy($targetFile, $targetPath . stripslashes($chain.".jpg")); //Avec Iconv //Grecque $chain = " $i vers $j "." ".iconv($i, $j."//TRANSLIT", "Λίπη"); copy($targetFile, $targetPath . stripslashes($chain." inconvTest.jpg")); } }