|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2829 writing in a file with fwrite()
Submitted: 1999-11-25 16:04 UTC Modified: 2001-02-10 15:24 UTC
From: arthur dot angelier at iq3 dot nl Assigned:
Status: Closed Package: Other
PHP Version: 3.0.11 OS: Windows NT
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
46 - 32 = ?
Subscribe to this entry?

 [1999-11-25 16:04 UTC] arthur dot angelier at iq3 dot nl
First of all, i like PHP verry much.
It's an easy to learn and very usefull language.
Still i have a little problem.

I open a file with fopen() and i read in it with fread().
Then i set the filepointer with fseek() and i verify that
action with ftell().
So far all goes well.
But when i write to the file with fwrite(), i find that
the bytes i wrote are always appended to the file and not
written somewhere in the middle, at the position that i
placed the filepointer on.

So if i have a file with, let's say, 20 bytes (0 - 19),
and i position the filepointer at byte 10, then i should be
able to write in the middle of the file, right?
This doesn't happen.

And how can i truncate an opened file to a specific length?
I want to truncate this file with 20 bytes to a length of
14 bytes. How can i do this?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-26 15:55 UTC]

for #2 there is a ftruncate() function available in php4

for #1: if this still doesn't work with current php3 (or php)
        i'd like to see some sample code 
 [2001-02-10 15:24 UTC]
no feedback, closing.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jun 03 17:03:37 2023 UTC