nada Posted February 22, 2014 Share Posted February 22, 2014 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"); Link to comment Share on other sites More sharing options...
davej Posted February 23, 2014 Share Posted February 23, 2014 (edited) 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 February 23, 2014 by davej Link to comment Share on other sites More sharing options...
nada Posted February 23, 2014 Author Share Posted February 23, 2014 yes my dear , I can retrive arabic string from DB Link to comment Share on other sites More sharing options...
justsomeguy Posted February 24, 2014 Share Posted February 24, 2014 So what exactly is the problem? What happens when you run the code? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now