Jump to content

Help using filesize() function


foxclone

Recommended Posts

I'm trying to get the filesize() of a file based on a retrieval of filename from the database. The file is located in the download directory and the code calling the function is in the root of the website. Here's the code I've tried:

$test = $pdo->query("SELECT filename FROM files WHERE id =1");
   $isoname = $test->fetchColumn();
   $test = "download/".$isoname;
   $isosize = filesize($test)/1000000;

It always returns zero although is returns the correct filename.

 

Thanks for any guidance in advance.

Link to comment
Share on other sites

  • 2 weeks later...

gw1500se is probably correct here, 

Quick update

$test = $pdo->query("SELECT filename FROM files WHERE id =1");
$isoname = $test->fetchColumn();
$test = "download/".$isoname;
if(!file_exists($test))  die("File missing:".$test); //<--added for testing
$isosize = filesize($test)/1000000;

 

Might be a path update like

$test = __DIR__."/download/".$isoname;

 

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.