filesize() returns 0


Posted on 16th Feb 2014 07:03 pm by admin

I have a socket program that runs in an infinite loop, listening for connections, in this socket I have a method, that is supposed to open a file and write to the file, but I am having issues. Each call to the socket happens about once every 1.5 seconds, and then, it writes to the socket, but for some reason, filesize is always returning "0" even when the file is 1.5kb in size.

I use a string var to to defiine the file and it's positions:
var $file = 'C:php_filesPhediatest.flv';

Why is it returning 0? It writes to the file fine, so why cant it get the correct size?

this function is ran about every 1.5 seconds, it is supposed to append the new data to the current file:
function dataRecieved($allclient, $socket, $buf) {
echo filesize($this->file)."nn";
$this->handle = fopen($this->file, "a+b");
if(filesize($this->file) < 1){
$buf = "FLV".pack('C', 1).pack('C', 1).pack('N', 9).pack('N', 9).$buf;
}
if(fwrite($this->handle, $buf)){
echo "Wrote to filen";
echo $buf;
}
fclose($this->handle);
}

No comments posted yet

Your Answer:

Login to answer
258 Like 35 Dislike
Previous forums Next forums
Other forums

Warning message
I've put a website that I was doing live and I'm getting this warning message when I try to add a ne

What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin

Simple Variable Question
Hi everyone.... again,

I am really getting into php still. Learning more every day. I love it

php is not recognized as an internal or external command
Hello,

I am trying to bake the code in CakePHP through my console.
I have changed my Path

SQL Query/echo not working
Hey all,

I'm trying to run (what I thought) was a simple operation and it isn't working. I h

Firewall / visited websites logger
Hi. I have a firewall implementation and I want to log all the websites visited on the machine. S

How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor

Problems with array
This code is the last lines in an upload script that uploads 4 images at the same time and writes th

sendmail code suddenly not working
Hi Guys, I maintain 3 sites (including my own) I use the following code from a french webmaster that

Sending a hyperlink through mail
HI all,
I am sending a mail to outlook mailbox of a user using FM SO_NEW_DOCUMENT_ATT_S

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash