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

redirect standard error and assert (how to?)
How do you redirect standard error and assert?

---

(Why? I am creating an web app and

Adding to an Int row in db
Hi, i have a database which houses all of the users of my site. One of the columns is for points whi

Fetching array then reversing it
Hi, I have a simple problem, I'll try to explain it as best I can:
News entries in my database ar

How can i steam a video on my PHP site? (non YouTube)
Basically I have a PHP site and don't want to give page rank to YouTube. I just want to stream a bas

What makes a script your own?
If someone finds a login script online, and changes some variable names around and some other minor

Looping Problem
I've got a client that has a database with about 200 events at any given time. I'm trying to loop t

date function help
i need help with date function

Code: [Select]<!DOCTYPE HTML PUBLIC "-//W3C//DTD H

Get to know your fellow coder
I think it's time we got personal around here. There's a lot of code swapping and a few members kno

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..

Log $_POST
How would i log submits on a form, by everyone? I want to then echo the number of submissions.

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