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

Error in query: Resource id #4??
hey guys, having a minor (i think) problem here that i havent been able to figure out. long story sh

Accessing element of object array
Hello

My object looks like this:


Array ( [0] => User Object ( [id] =>

double and single quotes in text fields acting up... help please
Single quotes, when entered into a text field, create an sql error upon Submit. It seems to create t

Help: problem with Headers to download PDF file
Hi,

I'm trying to implement a script where when a user clicks a link he gets a PDF file to op

Help with simple query
Hi,

I'm trying to do a Query with a Union where I want to print the number of rows $tc conta

Save remote XML to local website folder
Hi, I hope you can help me out. I would like to be able to pull an XML file from another site and t

need help to creat database
Hello Team, please guys i am stuck from three days with paypal issue for IPN but no luck yet now i w

Text file to .Dat file Conversion in PHP
Hi All,
Could anybody provide code for Text file to .Dat file Conversion in PHP.

Tha

Which PHP-Editor do you think is the best?
Hi everyone,
Myself Brian Anderson. For the last 2 years i have been working a

Getting Subdomain Name With PHP?
I want to grab the subdomain name with PHP so I can generate database queries.

for example my

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