Jump to content

filesize() [function.filesize]: stat failed...but it works???


ShootingBlanks

Recommended Posts

Hello.  I'm getting the following error:

 

Warning: filesize() [function.filesize]: stat failed for C:\WINDOWS\Temp\php1F7.tmp in D:\Inetpub\wwwroot\ManagersToolbox.anixter.com\Fastenermanagers\Toolbox\admin\uploadDocument.php on line 84

 

However, everything appears to be functioning in my application (despite that error).  Googling, it looked that that error appears when a directory is not writeable.  But the files are uploading fine, so I'm not sure why this error is happening.  Any ideas???

 

 

Link to comment
Share on other sites

It's likely that the file is inaccessible due to safe mode restrictions that apply to filesize(), but that the normal commands used to access the upload (I'll assume this an upload) file do have permissions.

 

If error_reporting was set to E_ALL, you would probably also be getting notice errors that would tell you why the filesize() statement is failing.

Link to comment
Share on other sites

If error_reporting was set to E_ALL, you would probably also be getting notice errors that would tell you why the filesize() statement is failing.

 

Is that something that I'd change in the .ini file?  (i ask because i'd have to get our company's IT department to do that)

 

This is odd.  I mean, everything on the application appears to be working fine.  I can upload files and then retrieve them with no problems (that's the general basis of the application).  I can't figure out what the warning/error would be indicating!...

Link to comment
Share on other sites

You can put the following two lines in your script for debugging purposes -

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

I still get the same error as before after doing that:

Warning: filesize() [function.filesize]: stat failed for C:\WINDOWS\Temp\php1FA.tmp in D:\Inetpub\wwwroot\ManagersToolbox.anixter.com\Fastenermanagers\Toolbox\admin\uploadDocument.php on line 87

 

What does a phpinfo(); statement show for safe mode?

 

It says it's "off" for both the local and master value.  What does that indicate?  Thanks again for the quick help!!!

 

Link to comment
Share on other sites

Can you post the code you are using this in? Maybe that will give us some hint on how to fix this issue for you.

 

There's a lot of code on the page, but this is the line that the error refers to:

 

// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($ftempname) > $max_filesize) {
$error[] = 'The file you attempted to upload is too large.<br />';
}

 

Then there's this part earlier on (which explains $max_filesize):

 

// *** Configuration - Your Options ***
$allowed_filetypes = array('.xls','.pdf','.doc','.ppt'); // Allowable file types
$max_filesize = 2097152; // Maximum filesize in BYTES (currently 2MB)
$upload_path = '../uploads/'.$folder.'/'; // Upload directory

 

And $ftempname is set here (even earlier still):

 

// *** set variables for $_FILES superglobal array ***
$fname = stripslashes($_FILES['userfile']['name']);
$ftype = $_FILES['userfile']['type'];
$fsize = $_FILES['userfile']['size'];
$ftempname = $_FILES['userfile']['tmp_name'];
$ferror = $_FILES['userfile']['error'];

 

Let me know if you need more info that that.  Thanks!...

 

 

Link to comment
Share on other sites

I am confused then, why not just use fsize to test the file size?

 

I think the issue would be within the temp folder, but not 100% sure.  You could, as an alternative base, do the move command on the file, then check the size, if the size is bad unlink that file.

 

But yea, why not just use the fsize?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.