Пример #1
0
 public function source()
 {
     $source = isset($_FILES[$this->options['input']]) ? $_FILES[$this->options['input']] : null;
     // prevent duplicate ios uploads
     // ios automatically uploads all images as image.jpg,
     // which will lead to overwritten duplicates.
     // this dirty hack will simply add a uniqid between the
     // name and the extension to avoid duplicates
     if ($source && f::name($source['name']) == 'image' && detect::ios()) {
         $source['name'] = 'image-' . uniqid() . '.' . ltrim(f::extension($source['name']), '.');
     }
     return $source;
 }
Пример #2
0
 public function source()
 {
     $source = isset($_FILES[$this->options['input']]) ? $_FILES[$this->options['input']] : null;
     // get the correct file out of multiple based on the "index" option
     if ($source && is_int($this->options['index']) && is_array($source['name'])) {
         $allSources = $source;
         $source = array();
         // get the correct value out of the $values array with all files
         foreach ($allSources as $key => $values) {
             $source[$key] = isset($values[$this->options['index']]) ? $values[$this->options['index']] : null;
         }
     }
     // prevent duplicate ios uploads
     // ios automatically uploads all images as image.jpg,
     // which will lead to overwritten duplicates.
     // this dirty hack will simply add a uniqid between the
     // name and the extension to avoid duplicates
     if ($source && f::name($source['name']) == 'image' && detect::ios()) {
         $source['name'] = 'image-' . uniqid() . '.' . ltrim(f::extension($source['name']), '.');
     }
     return $source;
 }