Jump to content

[SOLVED] fwrite is giving me junk in file


rbblue8

Recommended Posts

Hey all...

i get a file via a IMAP connection, and store it in $rawmessage.

i then call fwrite as follows.

[code]fwrite($FILE, utf8_encode($raw_message));
         fclose($FILE);
         $tempFileOK = TRUE;

and i have tried

fwrite($FILE, $raw_message);
         fclose($FILE);
         $tempFileOK = TRUE;

 

in the file that it creates..  i get very odd characters which is causing the next phase...  which reads that file..  to fail.  The character that i'm getting is ^M at the end of every line.

 

i then thought..  ok..  perhaps it's coming from the IMAP server..  well it's not..  for i then displayed all of $raw_message via [

code]echo $ram_message[/code]

and i do not get the ^M sign at all.

 

 

can you suggest a way to get rid of this when putting it to the file?

 

Link to comment
https://forums.phpfreaks.com/topic/89432-solved-fwrite-is-giving-me-junk-in-file/
Share on other sites

if (file_put_contents($tempFile, $raw_message))
      {
   //$FILE = @fopen($tempFile, 'w');
         //fwrite($FILE, utf8_encode($raw_message));
         //fclose($FILE);
         $tempFileOK = TRUE;



         // run command
         // 
  //$web_dir='/web/hostouremail.com/webmail/data';
         $cmd = $command . ' cat < ' .$web_dir.''.$tempFile;

 

is still giving me the ^M at the end of every line of the file.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.