Jump to content

download file with Arabic name


Recommended Posts

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 :umnik2:

 

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");
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...