Exemple #1
0
 /**
  * Constructor
  *
  * Instantiate a file object based on a file that has been uploaded.
  *
  * @param  string $upload
  * @param  string $file
  * @param  int    $size
  * @param  array  $types
  * @throws Exception
  * @return void
  */
 public function __construct($upload, $file, $size = null, $types = null)
 {
     $lang = new Moc10_Language();
     // Check to see if the upload directory exists.
     if (!file_exists(dirname($file))) {
         throw new Exception($lang->__('Error: The upload directory does not exist.'));
     }
     // Check to see if the permissions are set correctly.
     if ($this->_checkPermissions(dirname($file)) != 777) {
         throw new Exception($lang->__('Error: Permission denied.'));
     }
     // Move the uploaded file, creating a file object with it.
     if (move_uploaded_file($upload, $file)) {
         chmod($file, 0777);
         parent::__construct($file, true, $types);
         // Check the file size requirement.
         if (!is_null($size) && $this->size > $size) {
             $this->delete();
             throw new Exception($lang->__('Error: The file uploaded is too big.'));
         } else {
             if (is_null($size) && !is_null($this->_max) && $this->size > $this->_max) {
                 $this->delete();
                 throw new Exception($lang->__('Error: The file uploaded is too big.'));
             }
         }
     } else {
         throw new Exception($lang->__('Error: There was an error in uploading the file.'));
     }
 }
Exemple #2
0
 /**
  * Constructor
  *
  * Instantiate the JSDoc object.
  *
  * @param  string  $fle
  * @return void
  */
 public function __construct($fle)
 {
     parent::__construct($fle);
 }