Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Read a File in Binary Mode
How To Read a File in Binary Mode? - PHP Script Tips - Reading and Writing Files
✍: FYIcenter.com
If you have a file that stores binary data, like an executable program or picture file, you need to read the file in binary mode to ensure that none of the data gets modified during the reading process. You need to:
Here is a PHP script example on reading binary file:
<?php $in = fopen("/windows/system32/ping.exe", "rb"); $out = fopen("/temp/myPing.exe", "w"); $count = 0; while (!feof($in)) { $count++; $buffer = fread($in,64); fwrite($out,$buffer); } fclose($out); fclose($in); print("About ".($count*64)." bytes read.\n"); ?>
This script will print:
About 16448 bytes read.
This script actually copied an executable program file ping.exe in binary mode to new file. The new file should still be executable. Try it: \temp\myping dev.fyicenter.com.
2007-04-23, 5400👍, 0💬
Popular Posts:
How To Control Table Widths? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells Usually, b...
what is a service contract, operation contract and Data Contract? - part 1 In the below sample we ha...
What print out will the folloging code produce? main() { char *p1=“name”; char *p2; p2=(char*)malloc...
How To Use Subqueries with the IN Operator? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqu...
How do you handle change request? Normally change request are handled by preparing an Impact analysi...