|
|
Subject:
php reading and writing to binary files
Category: Computers > Programming Asked by: phoogoo-ga List Price: $25.00 |
Posted:
18 Sep 2004 20:16 PDT
Expires: 18 Oct 2004 20:16 PDT Question ID: 403105 |
|
There is no answer at this time. |
|
Subject:
Re: php reading and writing to binary files
From: fornn-ga on 22 Sep 2004 10:02 PDT |
int fwrite (int fp, string string [, int length]) fwrite() writes the contents of string to the file stream pointed to by fp. If the length argument is given, writing will stop after length bytes have been written or the end of string is reached, whichever comes first. |
Subject:
Re: php reading and writing to binary files
From: fornn-ga on 22 Sep 2004 10:03 PDT |
Purpose: Binary-safe file read Usage: string fread (int fp, int length) Availability: PHP 3, PHP 4 >= 4.0.0 fread() reads up to length bytes from the file pointer referenced by fp. Reading stops when length bytes have been read or EOF is reached, whichever comes first. // get contents of a file into a string $filename = "/usr/local/something.txt"; $fd = fopen ($filename, "r"); $contents = fread ($fd, filesize ($filename)); fclose ($fd); |
Subject:
Re: php reading and writing to binary files
From: indianguysiva-ga on 27 Sep 2004 04:53 PDT |
/* binary file read & write */ // for binary file read and write we have to use the mode 'b' b for binary //in php to open a binary file use $filename="xyz.pdf"; $fp=fopen($filename,"rb"); $contents=fread($fp,filesize($filename)); fclose($fp); /* in the contents u can modify what xmp u want */ again $filename="xyz.pdf"; $fp=fopen($filename,"wb"); if (fwrite($fp, $contents) === FALSE) { echo "Cannot write to file ($filename)"; exit; } fclose($fp); try with this method regards indianguysiva-ga |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |