Hi for all,
I am now develop web pages ,one of them is downloading and uploading file from DB and to DB
I programed it by php and it is OK when the file's name written in English ,the problem happened when the
file's name written in Arabic , I did not know where the problem exactly
notes:
1- I changed the encoding in DB to UTF-8.
2- Also in my code I try to encode it but still the problem not solved .
please try to help me
download code:
mysql_query("SET NAMES 'UTF8'");
mysql_query('SET CHARACTER SET utf8');
mysql_query('character_set_server=utf8');
if(isset($_GET['id2']))
{
// if id is set then get the file with the id from database
$id = $_GET['id2'];
$query = "SELECT attachname, attachtype, attachsize, attachment " .
"FROM additional_task WHERE ID = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($attachname,$attachtype,$attachsize,$attachment) = mysql_fetch_array($result);
header("Content-length:$attachsize");
if( $attachtype=="application/docx"){
header("Content-type: application/docx; charset=utf-8 ; filename=<utf8 byte sequence>'");
}
if( $attachtype=="application/pdf"){
header("Content-type: application/pdf; charset=utf-8 encoding=UTF-8'");
}
if( $attachtype=="application/png"){
header("Content-type: application/png; charset=utf-8 encoding=UTF-8'");
}
else{
header("Content-type: $attachtype; charset=utf-8 encoding=UTF-8'");
}
//$dncoded_fname = base64_decode($attachname);
header("Content-Disposition: attachment; filename=$attachname");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header("Content-Transfer-Encoding: binary");
ob_clean();
flush();
readfile("$attachname");