简体   繁体   中英

How can I most efficently pull everything from 0x0 to 0x***out of a file with PHP?

My PHP application involves selecting certain parts of an uploaded file and storing them in my database for easy retrieval. What I need to do is get everything between 0x0 and 0x6A0 (1696 bytes) and store them in the database. It includes binary characters like NUL and I'm a bit worried about sanitisation without ruining the file.

I need to do this while making sure that the first 8 bytes of the file are 50 41 52 41 .

Taken straight from fread manual page: http://www.php.net/manual/en/function.fread.php

Edited to remove the loop..

<?php
$handle = fopen("http://www.example.com/", "rb");
$contents = fread($handle, 1696);
fclose($handle);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM