Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $files = Input::file('images');
     $input = $request->all();
     $rules = array('file' => 'image|max:3000');
     $validator = Validator::make($files, $rules);
     if ($validator->fails()) {
         Session::flash('flash_message', 'Ошибка записи файлов!');
         return redirect()->back();
     } else {
         $destinationPath = 'uploads/images/';
         foreach ($files as $key => $file) {
             $filename[$key] = str_random(15) . '_' . substr($file->getClientOriginalName(), 0, strpos($file->getClientOriginalName(), ".")) . '.' . $file->getClientOriginalExtension();
             $upload_success = $file->move($destinationPath, $filename[$key]);
         }
     }
     foreach ($filename as $fname) {
         $image = new Image();
         $image->prod_id = $input['prod_id'];
         $image->path = $destinationPath . $fname;
         $image->save();
     }
     Session::flash('flash_message', 'Картинки успешно добавлены!');
     return redirect()->back();
 }
Example #2
0
 public static function addImage($product_id, $image)
 {
     $data = new Image();
     $data->product_id = $product_id;
     $data->path = $image;
     $data->save();
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     // Validation //
     /*
           $validation = Validator::make($request->all(), [
              'caption'     => 'required|regex:/^[A-Za-z ]+$/',
              'userfile'     => 'required|image|mimes:jpeg,png|min:1|max:250'
           ]);
     
           // Check if it fails //
           if( $validation->fails() ){
              return redirect()->back()->withInput()
                               ->with('errors', $validation->errors() );
           }
     */
     $image = new Image();
     // upload the image //
     $file = $request->file('userfile');
     $destination_path = 'uploads/';
     $filename = str_random(6) . '_' . $file->getClientOriginalName();
     $file->move($destination_path, $filename);
     // save image data into database //
     $image->file = $destination_path . $filename;
     $image->caption = $request->input('nome');
     //$image->description = $request->input('description');
     $image->produto_id = $request->input('produto_id');
     $image->isexist = "true";
     $image->save();
     return redirect('/')->with('message', 'You just uploaded an image!');
 }
Example #4
0
 public static function UploadImage($oriFilePath, $fileName, User $user, $diskName = null)
 {
     $fs = Storage::disk($diskName);
     $fileContent = $fs->get($oriFilePath);
     $mimeType = $fs->mimeType($oriFilePath);
     if (!str_is('image/*', $mimeType)) {
         $fs->delete($oriFilePath);
         throw new RequestValidationException(RequestValidationException::FileIsNotImage);
     }
     $fileModel = self::saveFileByFileContent($fileContent, $fileName, $mimeType, $user, $diskName);
     $fs->delete($oriFilePath);
     $image = Image::make($fileContent);
     $thumbnail = Image::make($fileContent)->widen(300)->encode($fileModel->mime);
     $thumbnailFileModel = FileManager::saveFileByFileContent($thumbnail->encoded, $fileModel->name . '-thumbnail.' . $fileModel->ext, $thumbnail->mime(), $user);
     if ($image->getWidth() > 1500) {
         $highResolution = Image::make($fileContent)->widen(1500)->encode($fileModel->mime);
         $highResolutionFileModel = FileManager::saveFileByFileContent($highResolution->encoded, $fileModel->name . '-high-resolution.' . $fileModel->ext, $highResolution->mime(), $user);
     } else {
         $highResolution = Image::make($fileContent)->widen($image->getWidth())->encode($fileModel->mime);
         $highResolutionFileModel = FileManager::saveFileByFileContent($highResolution->encoded, $fileModel->name . '-high-resolution.' . $fileModel->ext, $highResolution->mime(), $user);
     }
     $imageModel = new ImageModel();
     $imageModel->width = $image->getWidth();
     $imageModel->height = $image->getHeight();
     $imageModel->file()->associate($fileModel);
     $imageModel->thumbnailFile()->associate($thumbnailFileModel);
     $imageModel->highResolutionFile()->associate($highResolutionFileModel);
     $imageModel->save();
     return $imageModel;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     try {
         if (!$request->hasFile('photo')) {
             return $this->respondWithError('No photo is selected');
         }
         $file = $request->file('photo');
         // Create Eloquent object
         $image = new Image();
         $image->point_id = $request->id;
         $image->filename = $this->generate_random_string();
         $image->mime_type = $file->getClientMimeType();
         $image->base_64 = $this->convert_to_base_64($file);
         $image->created_by = Auth::user()->id;
         $image->updated_by = Auth::user()->id;
         if (!$image->save()) {
             // If creation fails
             // Return error response
             return $this->respondInternalError();
         }
         // Select latest row from DB
         $resp = $image->orderBy('id', 'DESC')->first();
         // return with Fractal
         return Fractal::item($resp, new \App\Transformers\ImageTransformer())->responseJson(200);
     } catch (Exception $e) {
         return $this->respondInternalError();
     }
 }
Example #6
0
 /**
  * Store a newly uploaded resource in storage.
  *
  * @return Response
  */
 public function store(ImageRequest $request)
 {
     $input = $request->all();
     if (Auth::user()->image != null) {
         $image = Auth::user()->image;
         $file = Input::file('image');
         $name = time() . '-' . $file->getClientOriginalName();
         $image->filePath = $name;
         $file->move(public_path() . '/images/', $name);
     } else {
         // Store records process
         $image = new Image();
         $this->validate($request, ['title' => 'required', 'image' => 'required']);
         $image->title = $request->title;
         $image->description = $request->description;
         $image->user_id = Auth::user()->id;
         if ($request->hasFile('image')) {
             $file = Input::file('image');
             $name = time() . '-' . $file->getClientOriginalName();
             $image->filePath = $name;
             $file->move(public_path() . '/images/', $name);
         }
     }
     $image->save();
     $user = Auth::user();
     return redirect('/' . $user->username);
 }
 protected function makeImage($file, $height, $width, $randomFilename, $thumbnail = null)
 {
     $md5 = md5_file($file->getRealPath());
     $img = Image::make($file)->fit($height, $width);
     $path = 'images/';
     if ($thumbnail != null) {
         $path = 'images/thumb/';
     }
     $image = Images::where('md5_hash', $md5)->first();
     if ($image === null or $image->thumbnail_file == null) {
         Clockwork::info('Storing on Filesystem');
         $img->save(storage_path() . '/app/' . $path . $randomFilename . '.png', 90);
     }
     if ($image === null and $thumbnail === null) {
         Clockwork::info('New Image');
         $image = new Images();
         $image->user_id = Auth::user()->id;
         $image->filename = $file->getClientOriginalName();
         $image->file = $randomFilename . '.png';
         $image->height = $height;
         $image->width = $width;
         $image->md5_hash = $md5;
     } elseif ($thumbnail != null and $image->thumbnail_file == null) {
         Clockwork::info('Thumbnail Updated');
         $image->thumbnail_file = $randomFilename . '.png';
     }
     $image->save();
     return $image;
 }
Example #8
0
 /**
  * Store a newly created resource in storage.
  *
  * @param integer $item_id
  * @param ImageFormRequest $request
  *
  * @return Response
  */
 public function store($item_id, ImageFormRequest $request)
 {
     $imageName = uniqid('img') . '.' . $request->file('image')->getClientOriginalExtension();
     $image = new Image(['item_id' => $item_id, 'image' => $imageName]);
     $image->save();
     $request->file('image')->move(base_path() . '/public/img/catalog/', $imageName);
     return redirect()->route('items.images.create', ['items' => $item_id])->with('status', 'Your image has been uploaded!');
 }
Example #9
0
 public function storeImage($userID, $imageName, $imagePath)
 {
     $storeImg = new Image();
     $storeImg->userID = $userID;
     $storeImg->imageName = $imageName;
     $storeImg->imagePath = $imagePath;
     $storeImg->save();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, Redirector $redirect)
 {
     $rules = ['name' => 'required', 'path' => 'required'];
     $this->validate($request, $rules);
     //if($id != null)
     //  $image = Image::findOrFail($id);
     //else
     $image = new Image();
     $image->name = $request->input('name');
     $image->save();
     $path = 'imgs/' . $image->id . '.' . $request->file('path')->getClientOriginalExtension();
     $image->path = $path;
     $image->save();
     Storage::disk('public')->put($path, file_get_contents($request->file('path')->getRealPath()));
     return $redirect->route("imagenes.index");
     //Storage::put('file.jpg',$request);
 }
Example #11
0
 public function create(UploadedFile $file, User $user)
 {
     $filename = sha1(rand(11111, 99999));
     $extension = $file->getClientOriginalExtension();
     Storage::put('images/' . $filename . '.' . $extension, file_get_contents($file->getRealPath()));
     $image = new Image(['user_id' => $user->id, 'filename' => $file->getClientOriginalName(), 'path' => $filename . '.' . $extension, 'mime_type' => $file->getMimeType(), 'location' => 'local', 'status' => Image::STATUS_PENDING]);
     $image->save();
     return $image;
 }
Example #12
0
 public function saveImagable()
 {
     $imageable = new Image();
     $imageable->path = $this->getPathWithFile();
     $imageable->imageable_id = $this->model_id;
     $imageable->imageable_type = $this->model_class_path;
     $imageable->r_id = $this->r_id;
     $imageable->save();
     return $imageable;
 }
Example #13
0
 /**
  * Helper untuk melakukan Add new Data ke dalam database
  * 
  */
 private function addData()
 {
     $data = new Image();
     $file = Input::file('gallery');
     $image_name = time() . "-gallery-" . $file->getClientOriginalName();
     $file->move(public_path() . '/upload', $image_name);
     $data->image = $image_name;
     $data->save();
     return true;
 }
Example #14
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'file' => 'required', 'caption' => 'required']);
     $image = new Image($request->except('file'));
     $request->file('file')->move(public_path('uploads/gallery'), $request->file('file')->getClientOriginalName());
     $image->file = $request->file('file')->getClientOriginalName();
     $image->save();
     flash()->success('Gambar telah ditambahkan!');
     return redirect('/dashboard/images');
 }
Example #15
0
 public function newPicture($fileName, $image)
 {
     $path = public_path('/images/gallery/');
     File::exists($path) or File::makeDirectory($path, 0755, true);
     $image->resize(200, 200)->save($path . $fileName);
     $picture = new Image();
     $picture->user = Auth::user()->name;
     $picture->caption = Input::get('caption');
     $picture->imagePath = 'images/gallery/' . $fileName;
     $picture->save();
 }
 public function saveAjax(Request $request)
 {
     $filename = $request->get('name') . '-' . uniqid() . '.' . $request->get('format');
     $data = $request->get('data');
     $data = file_get_contents($data);
     file_put_contents(public_path() . '/media/tmp/' . $filename, $data);
     $image = new Image();
     $image->name = $request->get('name');
     $image->user_id = \Auth::user()->id;
     $image->save();
     $image->addMedia(public_path() . '/media/tmp/' . $filename)->toMediaLibrary();
 }
 public function multipleUpload(Request $request)
 {
     // getting all of the post data
     $files = $request->file('images');
     $title = $request->input('title');
     $caption = $request->input('caption');
     if (sizeof($request->input('type')) > 0) {
         $types = $_POST['type'];
     }
     // Making counting of uploaded images
     $file_count = count($files);
     // start count how many uploaded
     $uploadcount = 0;
     foreach ($files as $file) {
         $rules = array('file' => 'required|mimes:png,gif,jpeg,jpg', 'title' => 'required|max:255', 'caption' => 'max:1000');
         $validator = Validator::make(array('file' => $file, 'title' => $title, 'caption' => $caption), $rules);
         if ($validator->passes()) {
             $size = $file->getSize();
             $destinationPath = './images/Amazing Lock Screen/';
             //upload path
             $extension = $file->getClientOriginalExtension();
             // get image extension
             $filename = time() . $file->getClientOriginalName() . '.' . $extension;
             //filename
             $file->move($destinationPath, $filename);
             // move
             $uploadcount++;
             $image = new Image();
             $image->title = $title;
             $image->caption = $caption;
             $image->url_path = $filename;
             $image->vote_count = 0;
             $image->user_id = Auth::user()->id;
             $image->size = $size;
             $image->save();
             if (sizeof($request->input('type')) > 0) {
                 foreach ($types as $type) {
                     $photoTag = new PhotoTag();
                     $photoTag->image_id = $image->id;
                     $photoTag->tag_id = $type;
                     $photoTag->save();
                 }
             }
         }
     }
     if ($uploadcount == $file_count) {
         Session::flash('success', 'Upload successfully');
         return Redirect::to('myphotos');
     } else {
         return Redirect::to('myphotos')->withInput()->withErrors($validator);
     }
 }
Example #18
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $google = App::make('App\\Services\\Google');
     $client = $google->getClient();
     $client->setAccessToken($this->image->user->access_token);
     $service = new Google_Service_Drive($client);
     $file = new Google_Service_Drive_DriveFile();
     $file->setTitle($this->image->filename);
     $file->setMimeType($this->image->mime_type);
     $data = Storage::get('images/' . $this->image->path);
     $createdFile = $service->files->insert($file, ['data' => $data, 'ocr' => true, 'mimeType' => $file->getMimeType(), 'uploadType' => 'multipart']);
     $exportLinks = $createdFile->getExportLinks();
     $plainTextUrl = $exportLinks['text/plain'];
     $request = new Google_Http_Request($plainTextUrl, 'GET', null, null);
     $httpRequest = $service->getClient()->getAuth()->authenticatedRequest($request);
     if ($httpRequest->getResponseHttpCode() == 200) {
         $this->image->text = $httpRequest->getResponseBody();
         $this->image->status = Image::STATUS_COMPLETE;
         $this->image->save();
         $service->files->delete($createdFile->getId());
     }
 }
Example #19
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // 'filename','featured','imageable_id','imageable_type','covered','title'
     $file = \Input::file('file');
     $filename = str_random(2) . '-' . $file->getClientOriginalName();
     $uploadSuccess = \Input::file('file')->move('uploads', $filename);
     if ($uploadSuccess) {
         $Image = new Image(\Input::all());
         $Image->filename = $filename;
         $Image->save();
         $this->resize('uploads', $filename);
         return $Image;
     }
 }
 public function save(Request $request)
 {
     $data = Input::get('image');
     list($type, $data) = explode(';', $data);
     list(, $data) = explode(',', $data);
     $data = base64_decode($data);
     $now = Carbon::now()->toDateTimeString();
     $random = strval(rand());
     $path = 'uploads/' . $now . '_' . $random . '.png';
     file_put_contents($path, $data);
     $image = new Image();
     $image->path = $path;
     $image->likes = 0;
     $image->save();
 }
 public function uploadPicture(UploadPictureRequest $request)
 {
     $input = Input::all();
     $fileName = $input['upload']->getClientOriginalName();
     $path = public_path('/images/gallery/');
     $image = Img::make($input['upload']->getRealPath());
     File::exists($path) or File::makeDirectory($path, 0755, true);
     $image->resize(375, 375)->save($path . $fileName);
     $picture = new Image();
     $picture->user = Auth::user()->name;
     $picture->caption = Input::get('caption');
     $picture->imagePath = 'images/gallery/' . $fileName;
     $picture->save();
     return redirect('/gallery');
 }
 public function store(Request $request)
 {
     $image = new Image();
     $this->validate($request, ['title' => 'required', 'image' => 'required']);
     $image->title = $request->title;
     $image->description = $request->description;
     if ($request->hasFile('image')) {
         $file = Input::file('image');
         //getting timestamp
         $timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
         $name = $timestamp . '-' . $file->getClientOriginalName();
         $image->filePath = $name;
         $file->move(public_path() . '/images/', $name);
     }
     $image->save();
     //    return $this->create()->with('success', 'Image Uploaded Successfully');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $photo = Request::file('image');
     $notes = Request::input('notes');
     $image = new App\Image();
     $image->make($photo, $notes);
     $image->name = $image->getName();
     $image->latitude = $image->getLatitude();
     $image->longitude = $image->getLongitude();
     $image->date = $image->getDate();
     $image->time = $image->getTime();
     $image->notes = $notes;
     $image->created_at = Carbon::now();
     $image->updated_at = Carbon::now();
     $image->save();
     return redirect()->action('AlleyController@create');
 }
 public function store(Request $request)
 {
     $image = new Image();
     $this->validate($request, ['title' => 'required', 'image' => 'required']);
     $image->title = $request->title;
     $image->description = $request->description;
     $image->user_id = Auth::user()->id;
     if ($request->hasFile('image')) {
         $file = Input::file('image');
         $timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
         $name = $timestamp . '-' . $file->getClientOriginalName();
         $image->filePath = $name;
         $file->move(public_path() . '/images/', $name);
     }
     $image->save();
     $returned_text = $this->tesseract($image->filePath);
     return view("imageupload")->with('success', $returned_text);
 }
Example #25
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ArticleRequest $request)
 {
     if ($request->file('image')) {
         $file = $request->file('image');
         $name = 'blogfacilito_' . time() . '.' . $file->getClientOriginalExtension();
         $path = public_path() . '/images/articles/';
         $file->move($path, $name);
     }
     $article = new Article($request->all());
     $article->user_id = \Auth::user()->id;
     $article->save();
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->name = $name;
     $image->article()->associate($article);
     $image->save();
     Flash::success('Se ha creado el articulo ' . $article->title . ' de forma exitosa!!');
     return redirect()->route('admin.articles.index');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Validation //
     $validation = Validator::make($request->all(), ['userfile' => 'required|image|mimes:jpeg,png|min:1|max:250']);
     // Check if it fails //
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     $image = new Image();
     // upload the image //
     $file = $request->file('userfile');
     $destination_path = 'uploads/';
     $filename = str_random(6) . '_' . $file->getClientOriginalName();
     $file->move($destination_path, $filename);
     // save image data into database //
     $image->file = $destination_path . $filename;
     $image->save();
     return redirect('/gallery')->with('message', 'You just uploaded an image!');
 }
Example #27
0
 /**
  * Store a newly created resource in storage.
  *
  * will always save new images as jpg's
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if (!$request->file('image')) {
         App::abort(404);
     }
     // ImageHandler instance
     $imageHandler = new ImageHandler($request->file('image')->getRealPath());
     // save resized image
     $name = $imageHandler->resize(1000)->save(public_path() . '/images/');
     // save thumb
     $imageHandler->resize(500)->save(public_path() . '/images/thumbs/');
     // save image to database
     $img = new Image();
     $img->path = $name;
     $img->description = $request->get('description');
     $img->front_page = (int) $request->get('front_page');
     $img->image_type_id = $request->get('type');
     $img->save();
 }
 public function store(ArticleRequest $request)
 {
     if ($request->file('image')) {
         $file = $request->file('image');
         $name = "blogfacilito_" . time() . bcrypt(\Auth::user()) . "." . $file->getClientOriginalExtension();
         $path = public_path() . "/images/articles/";
         $file->move($path, $name);
     }
     $article = new Article($request->all());
     $article->user_id = \Auth::user()->id;
     $article->save();
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->name = $name;
     $image->article()->associate($article);
     $image->save();
     Flash::success("El articulo " . $article->title . " se ha creado satisfactoriamente!");
     return redirect()->route('admin.articles.index');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ArticleRequest $request)
 {
     //Img handle
     if ($request->file('image')) {
         $file = $request->file('image');
         $name = 'laravel_' . time() . '.' . $file->getClientOriginalExtension();
         $path = public_path() . '\\images\\articles\\';
         $file->move($path, $name);
     }
     $article = new Article($request->all());
     $article->user_id = \Auth::user()->id;
     $article->save();
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->name = $name;
     $image->article()->associate($article);
     $image->save();
     Flash::success('Se ha creado el artículo ' . $article->title . ' correctamente.');
     return redirect()->route('admin.articles.index');
 }
 public function store(ArticleRequest $request)
 {
     if ($request->file('image')) {
         //Manipulacion de imagenes
         $file = $request->file('image');
         $name = substr($file->getClientOriginalName(), 0, -4) . "_" . time() . '_image.' . $file->getClientOriginalExtension();
         $path = base_path() . '/public/images/articles/';
         $file->move($path, $name);
         $image->name = $name;
     }
     $article = new Article($request->all());
     $article->user_id = \Auth::user()->id;
     $article->save();
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->article_id = $article->id;
     //$image->article()->associate();
     $image->save();
     Flash::success('Se ha agregado el articulo de forma satisfactoria.');
     return redirect()->route('admin.articles.index');
 }