PHP Classes

"File Upload by Focux" class

Recommend this page to a friend!

      File Upload by Focux  >  All threads  >  "File Upload by Focux" class  >  (Un) Subscribe thread alerts  
Subject:"File Upload by Focux" class
Summary:begs improvement
Messages:1
Author:Yakim
Date:2013-02-06 08:11:14
 

  1. "File Upload by Focux" class   Reply   Report abuse  
Picture of Yakim Yakim - 2013-02-06 08:11:14
if (@file_exists($this->folder . sha1_file($this->tmp_name) . time() . $this->name))
{
$this->error = 3;

Because sha1_file() is an expensive operation, and the target directory may contain (for instance) 1000+ huge PDF files... better if the code would perform comparison based ONLY the filesize. If an identical-sized file is found, perform sha1_file() comparison between that file and the uploaded file.

Also, a hardcoded error3 string is not useful.
Included in the error message should be the filename of the identical, pre-existing file.