Warning: filesize() [function.filesize]: stat failed

I have added some file upload fields to a custom admin menu in the backend of wordpress. This is on a multisite installation with the uploaded files going to the blogs.dir/store-name directory in wp-content. For each new store in the network, if the blogs.dir/store-name folder doesn’t already exist, it creates it. However I am receiving the folloing errors the first time I use the file upload for each site:

Warning: filesize() [function.filesize]: stat failed for /tmp/php988u62 in /home/ckfash/public_html/wp-admin/includes/ms.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /home/ckfash/public_html/wp-admin/includes/ms.php:31) in /home/ckfash/public_html/wp-includes/pluggable.php on line 890

It always works fine on the second attempt. My first impression was a permissions issue when attempting to set up the folder if it doesnt exsist (which it wont for most sites) and returns the error even tho the folder is successfully setup? I have set the permissions to 777 for the blogs.dir directory and all its children and files.

Any ideas?

I googled “Warning: filesize() [function.filesize]: stat failed” and got some interesting info from some of the links but they don’t mean much to me.

hopefully they will help you.

Yeah I read all sorts if stuff when I googled it, but none of it really helped me.

Since the error only happens the first time, I think its because after it creates the folder and tries to write to it, it gets the error. But the second time the folder is already created so it bypasses what causes the error.

This is new too me so I’m not really sure.

A quick google gave me two possible causes:

  1. /tmp is not writable by PHP - then filesize() is not allowed there … apparently. Try moving the file to the dir you want it (move_uploaded_file) and do a filesize() there to test.

  2. if you upload files of 2GB+ on *nix