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, 5302👍, 0💬
Popular Posts:
How To Select All Columns of All Rows from a Table? - MySQL FAQs - SQL SELECT Query Statements with ...
What is a delegate ? Delegate is a class that can hold a reference to a method or a function. Delega...
What Is the "@SuiteClasses" Annotation? "@SuiteClasses" is a class annotation defined in JUnit 4.4 i...
How To Call a Sub Procedure? - Oracle DBA FAQ - Creating Your Own PL/SQL Procedures and Functions To...
Are risk constant through out the project ? * Never say that risk is high through out the project. R...