Re: magical file writing truncation
| From: | skate | Date: | Fri, 08 Aug 2003 13:28:25 +0000 |
| Subject: | Re: magical file writing truncation | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158824@lists.php.net to get a copy of this message | ||
>
> obviously there's no simple solution here... can anyone point me in the
way
> of an alternative way of doing this? i could try the file write in 3
stages,
> first part of content, text, end of content, as they seem to write fine
> seperatly.
>
this is magical, evening seperating the file open, and file write into 3
stages, it still looses half my $text, but again, if i write $text to it's
own file, then it's perfectly fine, and all contents go inside...
i have this...
print "start: ".strlen($newStartContent)."<br />";
print "text: ".strlen($text)."<br />";
print "end: ".strlen($newEndContent)."<br />";
touch($newFile);
$fp = fopen($newFile, "ab");
$bytes = fwrite( $fp, $newStartContent );
$totalBytes += $bytes;
print " - ".$bytes." written";
fclose( $fp );
unset( $fp );
$fp = fopen($newFile.".txt", "at");
$bytes = fwrite( $fp, $text );
$totalBytes += $bytes;
print " - ".$bytes." written";
fclose( $fp );
unset( $fp );
$fp = fopen($newFile, "ab");
$bytes = fwrite( $fp, $newEndContent );
$totalBytes += $bytes;
print " - ".$bytes." written";
fclose( $fp );
unset( $fp );
print "<br />Total size written ".$totalBytes;
i figured i would totally kill $fp each time with an unset just incase. in
the above example the $text is being saved to a different file, and the
write is fine. take the ".txt" off so it saves to the same file, and it cuts
off half the $text again.
truly magical... i'm gonna have to rethink this whole thing aren't i? ah
well...
thanks again for the help...