The following code is part of a PHP web-service I\'ve written. It takes some uploaded Base64 data, decodes it, and appends it to a file. This all works fine.
PHP stores all file metadata it reads in a cache, so it's likely that the file size is already stored in that cache, and you need to clear it. See clearstatcache and call it before you call filesize.