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.tm p 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;
}
Warning: filesize() [function.filesize]: stat failed for C:\WINDOWS\TEMP\php1786.tm
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;
}
ASKER
What permission needs to be set in order for this to work? The file is able to be created.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I took your advice and changed the call to use the $_FILES variable.
-r-