Ejemplo n.º 1
0
 public function add(Request $request)
 {
     $name = Input::get('user_name');
     $id = Input::get('user_id');
     $text = Input::get('description');
     if ($request->hasFile('filefield')) {
         $file = $request->file('filefield');
         $entry = new Fileentry();
         $filename = time() . '.' . $file->getClientOriginalExtension();
         $extension = $file->getClientOriginalExtension();
         //			Image::make($file)->orientate()->save(public_path('recipe/'. $filename));
         Storage::disk('local')->put($file->getFileName() . '.' . $extension, File::get($file));
         $entry->mime = $file->getClientMimeType();
         $entry->original_filename = $file->getClientOriginalName();
         $entry->filename = $file->getFilename() . '.' . $extension;
     }
     $entry->user_name = $name;
     $entry->user_id = $id;
     $entry->description = $text;
     $entry->save();
     //		$file = Request::file('filefield');
     //		$extension = $file->getClientOriginalExtension();
     //		Storage::disk('local')->put($file->getFilename().'.'.$extension,  File::get($file));
     //		$entry = new Fileentry();
     //		$entry->mime = $file->getClientMimeType();
     //		$entry->original_filename = $file->getClientOriginalName();
     //		$entry->filename = $file->getFilename().'.'.$extension;
     //		$entry->user_name = $name;
     //		$entry->user_id = $id;
     //		$entry->description = $text;
     //
     //		$entry->save();
     return redirect('/');
 }
Ejemplo n.º 2
0
 public function addPicture($brand_id)
 {
     $file = Request::file('file');
     $extension = $file->getClientOriginalExtension();
     $path = 'brand/' . $brand_id . '/';
     $filename = $file->getFilename() . '.' . $extension;
     $fileStorage = new FileStorageController();
     $fileStorage->saveImage($path, $filename, $file);
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->path = $path . $filename;
     $entry->save();
     // now the image is saved
     //now we need to attach this image to our brand;
     $brand_image = new BrandImage();
     $brand_image->brand_id = $brand_id;
     $brand_image->fileentry_id = $entry->id;
     $brand_image->save();
     // Because this will be called via Ajax by DropZone
     // The response must be in JSON
     // - this is a 200 OK success
     return Response::json(['error' => false, 'code' => 200], 200);
 }
Ejemplo n.º 3
0
 public function postUpload(Request $req)
 {
     $response = array();
     if ($req->file('excelF')) {
         $file = $req->file('excelF');
         $extension = $file->getClientOriginalExtension();
         $filename = $file->getClientOriginalName();
         /*periksa extensi file */
         if ('xlsx' !== $extension) {
             $response['code'] = 404;
             $response['msg'] = "File berextensi {$extension} dengan nama {$filename}, file Seharusnya Berupa Excel";
             // $response['msg']="File Anda   $file->getClientOriginalName(), Pastikan File yang Anda upload sesuai dengan format ";
             return $response;
             // return $response;
         } elseif (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
             // simpan kedadalam table
             $entry = new Fileentry();
             $entry->mime = $file->getClientMimeType();
             $entry->original_filename = $file->getClientOriginalName();
             $entry->filename = $file->getFilename() . '.' . $extension;
             $entry->save();
             $response['code'] = 200;
             $response['msg'] = "File  {$entry->original_filename} Telah disimpan";
             return $response;
         }
     }
     $response['code'] = 404;
     $response['msg'] = "Gagal Upload File !!!";
     return json_encode($response);
     // echo '{"TEST1": 454535353,"TEST2": "test2"}';
 }
Ejemplo n.º 4
0
 public function addThumbnail($file)
 {
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->save();
     return $entry->id;
 }
Ejemplo n.º 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $file = $request->file('file');
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->save();
 }
Ejemplo n.º 6
0
 public function add()
 {
     $file = Request::file('filefield');
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->save();
     return redirect('fileentry');
 }
 public function add()
 {
     $file = Request::file('file');
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->save();
     //        if($extension == 'pdf'){
     //            Queue::push( new GenerateThumbnailCommand($entry));
     //        }
     return redirect('fileentry');
 }
 /**
  * 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|mimes:pdf|min:1|max:250']);
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     $fileentry = new Fileentry();
     // upload the file //
     $file = $request->file('userfile');
     $destination_path = 'files/';
     $filename = str_random(6) . '_' . $file->getClientOriginalName();
     $file->move($destination_path, $filename);
     // save file data into database //
     $fileentry->file = $destination_path . $filename;
     $fileentry->save();
     //*****************
     //NEEDS RETURN/REDIRECT
 }
 public function upload(Request $request)
 {
     Log::info('Uploading Files!');
     $file = $request->file;
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->model_id = "0";
     //create thumb for images
     if (strpos($file->getClientMimeType(), "image/") !== false) {
         $image = new ImageResize($file);
         $image->resizeToHeight(150);
         $entry->thumb = $image->getImageAsString();
     }
     $entry->save();
     return ['success' => false, 'data' => 200];
 }
Ejemplo n.º 10
0
 public function addPicture($article_id)
 {
     $file = Request::file('file');
     $extension = $file->getClientOriginalExtension();
     $path = 'article/' . $article_id . '/';
     $filename = $file->getFilename() . '.' . $extension;
     $thumb_filename = $file->getFilename() . '_thumb.' . $extension;
     $fileStorage = new FileStorageController();
     $fileStorage->saveImage($path, $filename, $file);
     $fileStorage->saveThumbnail($path, $thumb_filename, $file, 320, 150);
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->path = $path . $filename;
     $entry->thumbnail_path = $path . $thumb_filename;
     $entry->save();
     // now the image is saved
     //now we need to attach this image to our brand;
     $article_image = new ArticleImage();
     $article_image->article_id = $article_id;
     $article_image->fileentry_id = $entry->id;
     $article_image->save();
     // Because this will be called via Ajax by DropZone
     // The response must be in JSON
     // - this is a 200 OK success
     return Response::json(['error' => 'File could not be saved!', 'code' => 200], 200);
 }
Ejemplo n.º 11
0
 public function upload(Request $request, Note $note)
 {
     Log::info('Uploading Files!');
     $file = $request->file;
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->model_id = "note," . $note->id;
     $entry->save();
     return ['success' => false, 'data' => 200];
 }