Ejemplo n.º 1
0
 /**
  *  Perform file upload
  *
  * @access	public
  * @return	boolean
  */
 public static function uploadFiles($inputName, $path, $encryption = false, $newFilename = false, $overwrite = false)
 {
     $file = Input::file($inputName);
     // Instance object File
     $extension = $file->getClientOriginalExtension();
     $filename = $file->getClientOriginalName();
     $filenameOrg = $filename;
     if ($encryption) {
         mt_srand();
         $filename = md5(uniqid(mt_rand())) . "." . $extension;
     } elseif ($newFilename) {
         $filename = $newFilename . "." . $extension;
     }
     if (!$overwrite) {
         $i = 0;
         while (file_exists($path . '/' . $filename)) {
             $i++;
             if (!$encryption && !$newFilename) {
                 $baseName = basename($filenameOrg, '.' . $extension);
                 $filename = $baseName . '-' . $i . '.' . $extension;
             } elseif (!$encryption && $newFilename) {
                 $filename = $newFilename . '-' . $i . '.' . $extension;
             } else {
                 mt_srand();
                 $filename = md5(uniqid(mt_rand())) . "." . $extension;
             }
         }
     }
     $file->move($path, $filename);
     return $filename;
 }
Ejemplo n.º 2
0
 public function getInfoSrc()
 {
     $src = $this->documentRoot . Input::get('src');
     list($width, $height) = getimagesize($src);
     $response = ['success' => true, 'action' => 'getinfosrc', 'folder' => pathinfo($src, PATHINFO_DIRNAME), 'size' => filesize($src), 'oldName' => pathinfo($src, PATHINFO_BASENAME), 'extension' => pathinfo($src, PATHINFO_EXTENSION), 'width' => $width, 'height' => $height, 'name' => pathinfo($src, PATHINFO_FILENAME)];
     $data['json'] = json_encode($response);
     header('Content-type: application/json');
     echo $data['json'];
 }