문제

I am using a script to send a "$filename" variable from flash to PHP in order to create an xml file. The problem is that when I am typing Greek Characters as Filename the filename on the server gets values such as these for example: (δσωδσαωςεωςεβ.qxml)

I do not have any problem a) When writing english characters, b) When writing greek characters data in the xml file.

I am using file_put_contents function.

If instead of getting the Post variable as filename, I set my own filename such as "Ελληνικά.qxml" it works without a problem.

Thanks a lot in advance.

$string = $_POST['xmldata'];
$filename = $_POST['filename'];

$path = "test/";

//$dir_handle = @opendir($path) or mkdir("{$path}", 0777, true);

file_put_contents($path."/".$filename."", $string);

This problem was solved, but another arose. When I try to open the file from flash it does not recognise it now because it is in Greek.

도움이 되었습니까?

해결책

The problem is that flash is sending the data in different encoding. From the comments in the PHP manual for mb_convert_encoding I can see that you should use the following to get it to work (tested on danisch charactors and not greek)

<?php
$string = isset($_POST['xmldata'])?$_POST['xmldata']:"";
$filename = isset($_POST['filename'])?$_POST['filename']:"";

//tested on danish chars
/*
$string = mb_convert_encoding($string, "ISO-8859-1", "UTF-8");
$filename = mb_convert_encoding($filename, "ISO-8859-1", "UTF-8");
*/

//tested on greek chars
$string = mb_convert_encoding($string, "ISO-8859-7", "UTF-8");
$filename = mb_convert_encoding($filename, "ISO-8859-7", "UTF-8");

$path = "test/";

//$dir_handle = @opendir($path) or mkdir("{$path}", 0777, true);

file_put_contents($path."/".$filename."", $string);
?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top