示例#1
0
 /**
  * Save the image to the given path
  * @param  collection $request 
  * @return string or false    
  */
 public function storeImage($request)
 {
     $file = $request->file('image');
     $localPath = $this->localPath;
     // local folder where the file will be loaded to
     $fileName = sha1($request->input('name'));
     // $fileName = str_random(40); //username sha1ed, so it is unique
     $extension = "." . $file->getClientOriginalExtension();
     // $fileName = str_random(40); //username sha1ed, so it is unique
     $extendedName = $localPath . $fileName . $extension;
     $img = File::get($file);
     if (File::put($extendedName, $img)) {
         return $extendedName;
     }
     return false;
 }