Jump to content

download file with Arabic name


nada

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 comment
Share on other sites

Why do you want to store the files in the database?

 

Ignoring the file issue, can you successfully store and retrieve Arabic UTF-8 strings in the database?

Edited by davej
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...