Example #1
0
 function setMaxFileSize($size)
 {
     if (!isset($size) || !is_scalar($size)) {
         return;
     }
     $this->maxFileSize = sizeFromString($size);
 }
Example #2
0
 /**
  * @param file path or a stream
  * @param write mode
  * @return WriteFile object 
  */
 public function __construct($file)
 {
     if (is_array($file)) {
         $params = $file;
         if (isset($params['target'])) {
             $this->file = $params['target'];
         } else {
             throw new LogException("Param 'target' must be in config.ini");
         }
         if (isset($params['maxsize'])) {
             $this->maxsize = sizeFromString($params['maxsize']);
         }
         if (isset($params['maxcount'])) {
             $this->maxcount = $params['maxcount'];
         }
     } else {
         $this->file = $file;
     }
     $this->formatter = new FormatterSimple();
 }
Example #3
0
 /**
  * Pass only files with filesize between max and min values.
  * Caution, action performs at the calling time.
  *
  * @param int max file size
  * @param int min file size
  * @return UploadedFiles object
  * @see allowedImageSize
  */
 function allowedSize($max = null, $min = 0)
 {
     if ($min === null || $max === null) {
         return $this;
     }
     $min = sizeFromString($min);
     $max = sizeFromString($max);
     foreach ($this->http_files as $k => $v) {
         $size = sprintf("%u", @filesize($v['tmp_name']));
         if ($min && $size < $min) {
             $this->http_error_files[$k][] = array('min_size', $v['name'], sizeToString($min), $size);
         } elseif ($max && $size > $max) {
             $this->http_error_files[$k][] = array('max_size', $v['name'], sizeToString($max), $size);
         }
     }
     return $this;
 }
Example #4
0
 public function inlineAdd($path)
 {
     if (!is_file($path) || !is_readable($path)) {
         $this->errMsg('invalidFile', $path);
         return false;
     }
     $filename = basename($path);
     $this->attachmentName[] = $filename;
     $this->attachmentType[] = getMime($path);
     $this->attachmentPath[] = $path;
     $this->attachSize += filesize($path);
     $this->attachDispos[] = "inline";
     if ($this->attachSize >= max(sizeFromString(ini_get("memory_limit")), 4 * 1048576)) {
         $this->memoryLimit = true;
     }
 }