Jump to content

Recommended Posts

I have a folder with about 2,000 files in it.  Most are .mp3's and .pdf files.  The largest file is 50 MB.

 

This line of code:

$File_Size=filesize('Music_Library/'.$file);

is causing this error:

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

 

I add up the total file size so at the bottom of the page it will list the total number of files and total filesize that all files are taking up.  Works fine on my old php 4.2 server, but simply gives this error on 5.1.

 

Most of the help I found on Google doesn't seem to deal with my specific error.

Link to comment
https://forums.phpfreaks.com/topic/203996-filesize-error-worked-in-php-42-not-51/
Share on other sites

Given that you did not post the most important part of the error message (the part that states why it failed), I'll guess that your path is either not correct or the capitalization is not correct and you are on an operating system that is case sensitive.

Ok... so that's weird.  I get the File doesn't exist! like 1,000 times, and then it goes ahead and executes the code below and spits out the filenames and their sizes... how could the filename not exists and yet it executes fine?

 

The original error was this:

Warning: filesize() [function.filesize]: stat failed for Music_Library/zzc_this is a test file - delete.avi in /home2/sanjose3/public_html/downloads.php on line 22

I didn't think any of that other info would be all that useful.

 

I actually thought the code you gave me didn't mean anything since the files are obviously there and the path must be correct since it executes the code... this is where I'm puzzled.

So... after playing around a bit more.

 

The code still executes correctly and display the file names and sizes.  Granted, your code that you had me put in says the file does not exists.  Why would it say that the file is missing when it's clearly present?

PFMaBiSmAd, I think you are right.  After reviewing code previous... I convert all the filenames to lowercase because when a user searches for a filename, it converts their input to lowercase and compares so it's easier to find a filename.

 

I'm assuming that converting the filename to lowercase is why it cannot find the file.  For whatever reason, this worked fine in php 4.2.

 

Edit:  After testing that theory, when I removed the conversion to lowercase, it fixed everything.  Thank you for guiding me in the right direction!

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.