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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.