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, 5249👍, 0💬
Popular Posts:
How To Create an Add-to-Netvibes Button on Your Website? - RSS FAQs - Adding Your Feeds to RSS News ...
Give me the example of SRS and FRS SRS :- Software Requirement Specification BRS :- Basic Requiremen...
How To Select All Columns of All Rows from a Table? - MySQL FAQs - SQL SELECT Query Statements with ...
How To Control Table Widths? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells Usually, b...
What is the difference between Class and structure’s ? Following are the key differences between the...