예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $photoParent = PhotoParent::create($request->except('images', 'q'));
     // getting all of the post data
     $files = Input::file('images');
     $result = array();
     $file_count = count($files);
     // start count how many uploaded
     $uploadcount = 0;
     foreach ($files as $key => $file) {
         // $rules = array('file' => 'required'); //'required|mimes:png,gif,jpeg,txt,pdf,doc'
         // $validator = Validator::make(array('file'=> $file), $rules);
         // if($validator->passes()){
         $storage = \Storage::disk('public');
         $destinationPath = 'froala/uploads';
         $storage->makeDirectory($destinationPath);
         $filename = time() . $key . '.' . $file->getClientOriginalExtension();
         $upload_success = $file->move($destinationPath, $filename);
         $file_array = array();
         $file_array = array_collapse([$file_array, ['id' => $key + 1, 'name' => $filename]]);
         $result = array_add($result, $key, $file_array);
         $jsonresult = json_encode($result);
         //$files_ser = serialize($result);
         $photoParent->images = $jsonresult;
         $photoParent->save();
         $uploadcount++;
         // } // endif
     }
     return redirect()->route('admin.photoParent.index');
 }
예제 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $photoParent = PhotoParent::create($request->except('images', 'q', 'status'));
     // getting all of the post data
     $files = Input::file('images');
     $result = array();
     $file_count = count($files);
     if ($request->hasFile('status')) {
         $file = $request->file('status');
         $dir = 'img/thumbnail';
         $btw = time();
         $name = $photoParent->id() . $btw . '.' . $file->getClientOriginalExtension();
         $name2 = $photoParent->id() . $btw . '_big.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         //            Image::make($_FILES['status']['tmp_name'])->resize(250, 150)->save($dir.'/'.$name);
         Image::make($_FILES['status']['tmp_name'])->fit(250, 150)->save($dir . '/' . $name);
         Image::make($_FILES['status']['tmp_name'])->fit(300, 180)->save($dir . '/' . $name2);
         $photoParent->status = $dir . '/' . $name;
         $photoParent->thumbnail_big = $dir . '/' . $name2;
         $photoParent->save();
     }
     // start count how many uploaded
     $uploadcount = 0;
     //        dd($files);
     foreach ($files as $key => $file) {
         // $rules = array('file' => 'required'); //'required|mimes:png,gif,jpeg,txt,pdf,doc'
         // $validator = Validator::make(array('file'=> $file), $rules);
         // if($validator->passes()){
         $storage = \Storage::disk('public');
         $destinationPath = 'froala/uploads';
         $storage->makeDirectory($destinationPath);
         $filename = time() . $key . '.' . $file->getClientOriginalExtension();
         //            $upload_success = $file->move($destinationPath, $filename);
         //
         //            dd($_FILES['images']['tmp_name'][$key]);
         //
         //            dd($filename);
         Image::make($_FILES['images']['tmp_name'][$key])->heighten(600)->save($destinationPath . '/' . $filename);
         $file_array = array();
         $file_array = array_collapse([$file_array, ['id' => $key + 1, 'name' => $filename]]);
         $result = array_add($result, $key, $file_array);
         $jsonresult = json_encode($result);
         //$files_ser = serialize($result);
         $photoParent->images = $jsonresult;
         $photoParent->save();
         $uploadcount++;
         // } // endif
     }
     return redirect()->route('admin.photoParent.index');
 }
예제 #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $photoParent = PhotoParent::create($request->except('images', 'q', 'status'));
     // getting all of the post data
     $files = Input::file('images');
     $result = array();
     $file_count = count($files);
     if ($request->hasFile('status')) {
         $file = $request->file('status');
         $dir = 'img/thumbnail';
         $btw = time();
         $name = $photoParent->id() . $btw . '.' . $file->getClientOriginalExtension();
         $name2 = $photoParent->id() . $btw . '_big.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         //            Image::make($_FILES['status']['tmp_name'])->resize(250, 150)->save($dir.'/'.$name);
         Image::make($_FILES['status']['tmp_name'])->fit(250, 150)->save($dir . '/' . $name);
         Image::make($_FILES['status']['tmp_name'])->fit(300, 180)->save($dir . '/' . $name2);
         $photoParent->status = $dir . '/' . $name;
         $photoParent->thumbnail_big = $dir . '/' . $name2;
         $photoParent->save();
     }
     $uploadcount = 0;
     foreach ($files as $key => $file) {
         $storage = \Storage::disk('public');
         $destinationPath = 'froala/uploads';
         $storage->makeDirectory($destinationPath);
         $filename = time() . $key . '.' . $file->getClientOriginalExtension();
         Image::make($_FILES['images']['tmp_name'][$key])->heighten(600)->save($destinationPath . '/' . $filename);
         $file_array = array();
         $file_array = array_collapse([$file_array, ['id' => $key + 1, 'name' => $filename]]);
         $result = array_add($result, $key, $file_array);
         $jsonresult = json_encode($result);
         PhotoChild::create(['file' => $destinationPath . '/' . $filename, 'parentId' => $photoParent->id]);
         $photoParent->images = $jsonresult;
         $photoParent->save();
         $uploadcount++;
     }
     return redirect()->route('admin.photoParent.index');
 }