nada 0 Posted February 22, 2014 Report 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"); Quote Link to post Share on other sites
davej 251 Posted February 23, 2014 Report 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 Quote Link to post Share on other sites
nada 0 Posted February 23, 2014 Author Report Share Posted February 23, 2014 yes my dear , I can retrive arabic string from DB Quote Link to post Share on other sites
justsomeguy 1,135 Posted February 24, 2014 Report Share Posted February 24, 2014 So what exactly is the problem? What happens when you run the code? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.