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

PHP MySQL and DATE
Hi everyone

I have a databse and in one of the columns I have date values such as 2009-March-

PHP friend keyword equivalent
is there a PHP equivalent for the C++ friend keyword?

set xml path in flash when xml created in memorystream and webrequest
i am creating an xml file using memory stream and i want to load this xml file into the flash on cli

Class not found error
I am getting Class 'index' not found in Eval function:

//write config

$pat

simple php table loop
Hi all,

I've the following code

<?php // Create category options

Drawing Images in classes
I'm quite new to Object Oriented PHP. What I'm trying to do is draw some images but also have other

Hit counter updating once per IP - IP HIT COUNTER
I have a hit counter, for the amount of views on a tutorial.
It'll do the query and then do..

Seperate team from score
I am writing a site that does a NFL Pick 'em type application and I have a feed that gives me the sc

Access database inside of a validation class
Hello,

For quite some time, I have been using functions to validate form input and access the

Operating System
How in PHP or other language can I detect Operating system, ie Windows XP Home, Windows 7 Ultimate,

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