3

In php and windows7 as OS file saving as arabic name it gives like this مشرشىغش.I need save the file name with the arabic text only.

header("Content-Type:text/html;  charset=utf-8"); 
$name = $_GET['name'];
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) 
{
$filename = $name.".png";
file_put_contents($filename,$GLOBALS[ 'HTTP_RAW_POST_DATA' ]);
}

Please help me.

Thank you.

vamsi kr
  • 431
  • 1
  • 4
  • 13

1 Answers1

4

Try this:

header("Content-Type:text/html;  charset=utf-8"); 
$name = $_GET['name'];
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) 
{
  $encoding = mb_detect_encoding($name);
  $filename = iconv($encoding, "UTF-8", $name.".png");
  file_put_contents($filename,$GLOBALS[ 'HTTP_RAW_POST_DATA' ]);
}
Muhammet
  • 3,288
  • 13
  • 23