unicode convertion problem
Posted
by bhoomi-nature
on Stack Overflow
See other posts from Stack Overflow
or by bhoomi-nature
Published on 2010-05-19T06:05:20Z
Indexed on
2010/05/19
6:10 UTC
Read the original article
Hit count: 192
php
Hai frnds i am bhoomi new to php,i am having having below problem in my coding please can you help anyone
1.first i want to open one word document which is having content and i wann to edit it 2.for that i am opening word document from the server and at that time its opening with garbage value(i thing its not converting to utf8 format) 3.wen i delete that garbage value and insert something from textarea to that file it is going to insert and next time onwords its its getting open properly. 4.actually i wann that doc file should open with english words wats there in that doc instead of garbage value..first time opening only its giving problem. i am using below code for that please do the needful
$filename = 'test.doc';
if(isset($_REQUEST['Submit'])){ $somecontent = stripslashes($_POST['somecontent']); // Let's make sure the file exists and is writable first. if (is_writable($filename)) {
// In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit; }
// Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; }
echo "Success, wrote ($somecontent) to file ($filename) - Continue - ";
fclose($handle);
} else { echo "The file $filename is not writable"; } } else{ // get contents of a file into a string
$handle = fopen($filename, 'r');
$somecontent = fread($handle, filesize($filename));
?>
Edit file
© Stack Overflow or respective owner