Yogeswaran
Yogeswaran

Reputation: 1

Is that possible to modify a few bytes of a big file without have to rewrite the entire file again?

Is that possible to modify a few bytes of a big file without have to rewrite the entire file again? If it is possible, then how to do it? Or where I can find more information?

Upvotes: 0

Views: 51

Answers (1)

Dan Grossman
Dan Grossman

Reputation: 52372

Yes. Use fseek and fgets to read only those bytes you need. Use fopen with an appropriate non-truncating mode, fseek again to the correct offset, and fwrite to write as many bytes as you need into the file.

Reference: PHP Manual: Filesystem Functions

Upvotes: 2

Related Questions