Link to home
Start Free TrialLog in
Avatar of dyarosh
dyarosh

asked on

Problem implementing my File_Upload Class - 500 points

I'm getting the following error and I'm not sure why:

Warning: filesize() [function.filesize]: stat failed for C:\WINDOWS\TEMP\php1786.tmp in C:\Documents and Settings\username\My Documents\UploadFiles.php on line 140

Here is the code that the error refers to.  The function is defined within a class.  Can someone tell me if this is a coding problem or a permissions problem?

      // Returns file size in a user friendly, readable format
      function get_file_size() {
            // Define variables to be used by function
            $temp_file_name = trim($this->temp_file_name);
            $kb = 1024;
            $mb = 1024 * $kb;
            $gb = 1024 * $mb;
            $tb = 1024 * $gb;
            
            // Check to see if temp file name is valid, if not, return error.
            // Get the file size in bytes using filesize() function.  Return a readable file size.
            if ($temp_file_name)
            {
<HERE IS LINE 140>            $size = filesize($temp_file_name);
                  if ($size < $kb)
                  {
                        $file_size = "$size Bytes";
                  }
                  elseif ($size < $mb)
                  {
                        $final = round($size/$kb,2);
                        $file_size = "$final KB";
                  }
                  elseif ($size < $gb)
                  {
                        $final = round($size/$mb,2);
                        $file_size = "$final MB";
                  }
                  elseif ($size < $tb)
                  {
                        $final = round($size/$gb,2);
                        $file_size = "$final GB";
                  }
                  else
                  {
                        $final = round($size/$tb,2);
                        $file_size = "$final TB";
                  }
            }
            else
            {
                  $file_size = "ERROR: NO FILE PASSED TO get_file_size()";
            }
            return $file_size;
      }

Avatar of Roonaan
Roonaan
Flag of Netherlands image

My first hunch would be it is a permission problem.

-r-
Avatar of dyarosh
dyarosh

ASKER

What permission needs to be set in order for this to work?  The file is able to be created.
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dyarosh

ASKER

I took your advice and changed the call to use the $_FILES variable.