예제 #1
0
 public function multiple_upload(Request $request)
 {
     /*
      * Tests incoming files to make sure there's no duplicates in db
      */
     // getting all of the post data
     $files = Input::file('userfile');
     // Making counting of uploaded images
     $file_count = count($files);
     // start count how many uploaded
     $uploadcount = 0;
     $hash_type = 'md5';
     // don't change this on an existing database!
     $filepath = 'img/';
     $thumbpath = 'img/thumbs/';
     foreach ($files as $file) {
         if (in_array(exif_imagetype($file), array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
             $filename = $file->getClientOriginalName();
             $extension = strtolower($file->getClientOriginalExtension());
             $photo = new Photo();
             //photo db object
             $photo->filename = $filename;
             $photo->extension = $extension;
             $photo->save();
             $currImg = Image::make($file);
             $currFilePath = $filepath . $photo->id . "." . $extension;
             $currImg->orientate()->save($currFilePath);
             // saving the actual file
             $hashcheck = hash_file($hash_type, $currFilePath);
             $hasDuplicate = Photo::where('hash', $hashcheck)->first();
             if ($hasDuplicate) {
                 // rollback if duplicate found
                 File::delete($currFilePath);
                 $photo->delete();
             } else {
                 $currImg->heighten(174)->save($thumbpath . $photo->id . "_thumb" . "." . $extension);
                 $photo->hash = hash_file($hash_type, $currFilePath);
                 // hash generated after we save the file
                 $photo->notes = $request->input('note');
                 $photo->image_subject = "Rosemary";
                 $photo->save();
                 $uploadcount++;
             }
             $currImg->destroy();
             // free up memory
         }
     }
     return $file_count - $uploadcount;
 }
예제 #2
0
 public function updateAlbum(Request $request)
 {
     $albums = json_decode($request->all()['albums'], true);
     $len = count($albums);
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Album::truncate();
     Photo::truncate();
     Album::reindex();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     foreach ($albums as $a) {
         $album = new Album();
         $album->album_id = $a['id'];
         $album->name = $a['name'];
         $album->created_time = $a['created_time'];
         $album->save();
         $photos = $a['photos']['data'];
         foreach ($photos as $p) {
             $photo = new Photo();
             $photo->album_id = $album->id;
             $photo->photo_id = $p['id'];
             $photo->source = $p['source'];
             $photo->save();
         }
     }
     return '1';
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate(PhotoRequest $request)
 {
     $photo = new Photo();
     $photo->user_id = Auth::id();
     $photo->language_id = $request->language_id;
     $photo->name = $request->name;
     $photo->photo_album_id = $request->photo_album_id;
     $photo->description = $request->description;
     $photo->slider = $request->slider;
     $photo->album_cover = $request->album_cover;
     $picture = "";
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $picture = sha1($filename . time()) . '.' . $extension;
     }
     $photo->filename = $picture;
     $photo->save();
     if ($request->hasFile('image')) {
         $photoalbum = PhotoAlbum::find($request->photo_album_id);
         $destinationPath = public_path() . '/appfiles/photoalbum/' . $photoalbum->folder_id . '/';
         $request->file('image')->move($destinationPath, $picture);
         $path2 = public_path() . '/appfiles/photoalbum/' . $photoalbum->folder_id . '/thumbs/';
         Thumbnail::generate_image_thumbnail($destinationPath . $picture, $path2 . $picture);
     }
 }
예제 #4
0
 public function update(Request $request, Blog $blog, BlogPost $blogPost, Photo $photo)
 {
     // extra validation specific to adding an inscription
     $validator = $this->requireInscription($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $photo->inscription_title = $request['inscription_title'];
     $photo->inscription_content = $request['inscription_content'];
     $photo->save();
     return redirect(route('blog.blogPost.edit', ['blog' => getUrlForThisName($blog), 'blogPost' => getUrlForThisName($blogPost)]));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $categories = Category::all();
     foreach ($categories as $category) {
         $filename = sprintf('%s-Tour.jpg', str_replace([' ', '/'], '-', $category->name));
         $newPhoto = new Photo();
         $newPhoto->path = $filename;
         $newPhoto->imageable_id = $category->id;
         $newPhoto->imageable_type = 'App\\Category';
         $newPhoto->save();
     }
 }
예제 #6
0
 public function update(Request $request, $year, $month, $day)
 {
     $date = $this->createDate($year, $month, $day);
     $file = $request->file('photo');
     if (is_null($file)) {
         abort(400);
     }
     $photo = new Photo($date);
     $image = Image::make($file);
     $photo->save($image);
     return response(json_encode($photo->toArray()), 201)->header('Content-Type', 'application/json');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $packages = Package::all();
     foreach ($packages as $package) {
         $filename = sprintf('%s-Tour.jpg', str_replace(' ', '-', $package->name));
         $newPhoto = new Photo();
         $newPhoto->path = $filename;
         $newPhoto->imageable_id = $package->id;
         $newPhoto->imageable_type = 'App\\Package';
         $newPhoto->save();
     }
 }
 public function uploadPhotos(Request $request)
 {
     //adding image during image intervention
     $image = Input::file('image');
     $filename = time() . '-' . $image->getClientOriginalName();
     $path = $image->move('images\\photos', $filename);
     // Image::make($image->getRealPath())->resize('600','400')->save($path);
     $photo = new Photo();
     $photo->photo_name = $filename;
     $photo->album_id = $request->input('album_id');
     $photo->save();
     return redirect('profile');
 }
예제 #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //Here we will ceate a new object of model file called
     $photo = new Photo();
     $photo->name = $request->name;
     //$photo->path = $request->file("photoFile");
     $photo->user_id = $request->user_id;
     //I need to copy the file a give it some valid name
     $photo->path = "Photo" . $photo->user_id . ".png";
     $request->file("photoFile")->move(storage_path() . "/" . $photo->path);
     $photo->save();
     return redirect('/photo');
 }
예제 #10
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $photoDirectory = env('BH_PHOTO_DIRECTORY');
     $fileExtension = $this->file->getClientOriginalExtension();
     $fileName = str_random(10) . '.' . $fileExtension;
     $image = \Image::make($this->file->getRealPath());
     $image->resize(800, 800);
     $image->save($photoDirectory . '/photo_files/normal/' . $fileName);
     $image->resize(100, 100);
     $image->save($photoDirectory . '/photo_files/thumbnail/' . $fileName);
     $photo = new Photo();
     $photo->file_name = $fileName;
     $photo->save();
 }
 public function imageUpload(Request $request)
 {
     $rules = ['image' => 'required|image|mimes:jpeg'];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect('galerija')->withErrors($validator);
     } else {
         $name1 = str_random(6) . '.jpg';
         $request->file('image')->move('images/web/', $name1);
         $photo = new Photo();
         $photo->name = 'images/web/' . $name1;
         $photo->save();
         return redirect('galerija');
     }
 }
예제 #12
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');
     //Name
     $originalName = str_replace(' ', '', $file->getClientOriginalName());
     $originalName = str_replace('#', '_', $originalName);
     $filename = time() . $originalName;
     $image_size = $this->savePhoto($file, $filename);
     //make Database entries
     $photo = new Photo();
     $photo->filename = $filename;
     $photo->image_size = $image_size;
     $photo->album_id = $request->_id;
     $photo->user_id = \Auth::user()->id;
     $photo->save();
 }
예제 #13
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($id, Request $request)
 {
     foreach ($request->file('images') as $p) {
         $photo = new Photo();
         $photo->album_id = $id;
         $fileName = "";
         if ($p->isValid()) {
             $path = public_path() . '/uploads/photos/';
             $fileName = str_random(32) . '.' . $p->getClientOriginalExtension();
             $p->move($path, $fileName);
         } else {
             App::abort(404);
         }
         $photo->photo = $fileName;
         $photo->save();
     }
     return Redirect::route('admin.photos.show', $id);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(PhotoRequest $request)
 {
     $photo = new Photo($request->except('image'));
     $photo->user_id = Auth::id();
     $picture = "";
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $picture = sha1($filename . time()) . '.' . $extension;
     }
     $photo->filename = $picture;
     $photo->save();
     if ($request->hasFile('image')) {
         $photoalbum = PhotoAlbum::find($request->photo_album_id);
         $destinationPath = public_path() . '/appfiles/photoalbum/' . $photoalbum->folder_id . '/';
         $request->file('image')->move($destinationPath, $picture);
     }
 }
예제 #15
0
 public function upload($photo, $user_id, $album_id)
 {
     try {
         if (!Storage::disk('local')->exists($user_id)) {
             Storage::makeDirectory($user_id);
         }
         $destinationPath = public_path() . '/uploads/' . $user_id;
         $filename = str_random(10) . $photo->getClientOriginalName();
         $upload_success = $photo->move($destinationPath, $filename);
         if ($upload_success) {
             $photo = new Photo();
             $photo->name = $filename;
             $photo->user_id = $user_id;
             $photo->save();
             $photo->albums()->attach($album_id);
             return array('status' => 1, 'photo' => $photo);
         }
     } catch (Exception $exp) {
         return array('status' => 0);
     }
 }
예제 #16
0
 public function editSchool($id, Request $request)
 {
     $school = School::find($id);
     $school->bus = $request->input('bus');
     $school->save();
     if (Input::hasFile('images')) {
         $files = Input::file('images');
         foreach ($files as $file) {
             $destinationPath = 'uploads';
             $filename = $file->getClientOriginalName();
             $new_name = uniqid() . "." . File::extension($filename);
             $upload_success = $file->move(public_path() . "/" . $destinationPath, $new_name);
             $uploaded_files[] = $destinationPath . "/" . $new_name;
         }
         foreach ($uploaded_files as $file) {
             $photo = new Photo();
             $photo->school_id = $school->id;
             $photo->location = $file;
             $photo->save();
         }
     }
     return redirect(url('admin/school/' . $school->id))->with('success', 'Izmena je sacuvana');
 }
예제 #17
0
    $photo->nomphoto = $request->photo;
    $photo->idperle = $request->input('idperle');
    $photo->datephoto = $date;
    $photo->heurephoto = $heure;
    $photo->idutilisateur = $iduser;
    //On récupère le fichier photo dans un objet file
    //$request->input('photo');
    $file = Input::file('photo');
    //chemin du fichier
    //$path = Input::file('photo')->getRealPath();
    //echo $path;
    $destinationPath = 'Photos';
    $name = Input::file('photo')->getClientOriginalName();
    Input::file('photo')->move($destinationPath, $name);
    $photo->nomphoto = $name;
    if ($photo->save()) {
        return view('accueil_bootstrap');
    }
});
/* ------------ Ajout d'une anecdote ------------- */
Route::any('valider_ajout_anecdote', function (Request $request) {
    $date = date("Y-m-d");
    $heure = date("H:i:s");
    $iduser = Auth::user()->idutilisateur;
    $anecdote = new Anecdote();
    $anecdote->anecdote = $request->anecdote;
    $anecdote->idperle = $request->input('idperle');
    $anecdote->dateanecdote = $date;
    $anecdote->heureanecdote = $heure;
    $anecdote->idutilisateur = $iduser;
    if ($anecdote->save()) {
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ProductRequest $request, $id)
 {
     $product = Product::find($id);
     $product->name = $request->name;
     $product->price = $request->price;
     $product->description = $request->description;
     $product->category_id = $request->category_id;
     $product->resluggify();
     $product->save();
     //Upload file
     if ($request->hasFile('file')) {
         $files = $request->file('file');
         foreach ($files as $file) {
             $rules = array('file' => 'mimes:png,jpeg,jpg');
             //'required|mimes:png,gif,jpeg,txt,pdf,doc'
             $validator = Validator::make(array('file' => $file), $rules);
             if ($validator->passes()) {
                 $destinationPath = 'uploads';
                 $filename = time() . '-' . $file->getClientOriginalName();
                 $path = $destinationPath . '/' . $filename;
                 $success = $file->move($destinationPath, $filename);
                 if ($success) {
                     $thumbPath = 'uploads/thumbs/';
                     $thumb1 = Image::make($path)->resize(270, 180)->save($thumbPath . $filename);
                     $photo = new Photo();
                     $photo->title = $filename;
                     $photo->product_id = $id;
                     $photo->save();
                 }
             }
         }
     }
     return redirect()->route('admin.product.edit', $product->slug);
 }
예제 #19
0
 public function postNew(Request $request)
 {
     $validation = Validator::make($request->all(), ['title' => 'required|min:3', 'photo' => 'required|image', 'tags' => 'required']);
     if ($validation->fails()) {
         return redirect()->back()->withInput()->withErrors($validation);
     }
     //Upload the image and return the filename and full path
     $upload = Photo::upload($request->file('photo'));
     //Tag Stuff
     //First, create(if needed) and return IDs of tags
     $tagIds = Tag::createAndReturnArrayOfTagIds($request->get('tags'));
     //If user wants to read the tags (keywords) from the file, then we need to fetch them from uploaded file.
     if ($request->has('read_tags_from_file')) {
         $exif = exif_read_data($upload['fullpath'], 'ANY_TAG', true);
         if ($exif) {
             if (array_key_exists('IFD0', $exif)) {
                 if (array_key_exists('Keywords', $exif['IFD0'])) {
                     //array_unique, because same tags may be on both the form and the file, but only one is added to the database
                     //Keywords are delimited by semicolon ( ; ) in the EXIF tag data.
                     $tagIds = array_unique(array_merge($tagIds, Tag::createAndReturnArrayOfTagIds($exif['IFD0']['Keywords'], ';')));
                 }
             }
         }
     }
     //Tag Stuff end
     $photo = new Photo();
     $photo->user_id = Auth::user()->id;
     $photo->title = $request->get('title');
     $photo->image = $upload['filename'];
     $photo->save();
     //Now attach the tags, since this is creating method, attach() is okay
     $photo->tags()->attach($tagIds);
     return redirect()->back()->withSuccess('Photo Created Successfully!');
 }
 public function insertData()
 {
     $logged_in_user = User::find(1);
     //return $logged_in_user->id;
     for ($x = 0; $x < 5; $x++) {
         $email = rand() . '@gmail.com';
         $user = new User();
         $user->name = rand();
         $user->email = $email;
         $user->password = $email;
         $user->save();
         $logged_in_user->followers()->attach($user->id);
         if ($x > 5) {
             $logged_in_user->following()->attach($user->id);
         }
     }
     /* 
       $photos = array(
           array(
               'user_id' => $logged_in_user->id,
               'location' => 'http://farm6.staticflickr.com/5044/5319042359_68fb1f91b4.jpg',
               'description' => 'Dusty Memories, The Girl in the Black Beret (http://www.flickr.com/photos/cloudy-day/)'
           ),
           array(
               'user_id' => $logged_in_user->id,
               'location' => 'http://farm3.staticflickr.com/2354/2180198946_a7889e3d5c.jpg',
               'description' => 'Rascals, Tannenberg (http://www.flickr.com/photos/tannenberg/)'
           ),
           array(
               'user_id' => $logged_in_user->id,
               'location' => 'http://farm7.staticflickr.com/6139/5922361568_85628771cd.jpg',
               'description' => 'Sunset, Funset, Nikko Bautista (http://www.flickr.com/photos/nikkobautista/)'
           )
       );
       $logged_in_user->photos()->save($photos);  
     */
     $photo = new Photo();
     $photo->user_id = $logged_in_user->id;
     $photo->location = 'http://farm6.staticflickr.com/5044/5319042359_68fb1f91b4.jpg';
     $photo->description = 'Dusty Memories, The Girl in the Black Beret (http://www.flickr.com/photos/cloudy-day/)';
     $photo->save();
     $photo1 = new Photo();
     $photo1->user_id = $logged_in_user->id;
     $photo1->location = 'http://farm3.staticflickr.com/2354/2180198946_a7889e3d5c.jpg';
     $photo1->description = 'Rascals, Tannenberg (http://www.flickr.com/photos/tannenberg/)';
     $photo1->save();
     $photo2 = new Photo();
     $photo2->user_id = $logged_in_user->id;
     $photo2->location = 'http://farm7.staticflickr.com/6139/5922361568_85628771cd.jpg';
     $photo2->description = 'Sunset, Funset, Nikko Bautista (http://www.flickr.com/photos/nikkobautista/)';
     $photo2->save();
 }
예제 #21
0
 /**
  * @expectedException Illuminate\Database\QueryException
  */
 public function testMorphOneToManySaveOrder3()
 {
     $photo = new Photo();
     $photo->desc = 'photo 4';
     $photo->photoable_id = 0;
     $photo->photoable_type = '';
     $photo->save();
     $id = $photo->id;
     $photo = Photo::find($id);
     $this->assertEquals('photo 4', $photo->desc);
     $phone = new Phone();
     $phone->number = '555';
     $phone->user_id = 3;
     $phone->photos()->save($photo);
     $phone->save();
 }
 /**
  * @param UploadedFile $photo
  * @param $id
  */
 public function storeImages(UploadedFile $photo, $id)
 {
     $filename = time() . $photo->getClientOriginalName();
     $path = public_path('images/home_pics');
     $photo->move($path, $filename);
     $image = new Photo();
     $image->flyer_id = $id;
     $image->path = $filename;
     $image->save();
 }
예제 #23
0
 protected function add_photo($photo)
 {
     $add_photo = new Photo();
     $add_photo->name = $this->get_name($photo->getClientOriginalName());
     $add_photo->original_url = '';
     $add_photo->url = $this->base_dir . '/' . $add_photo->name;
     $add_photo->preview_url = $this->thumbnail_dir . '/' . $add_photo->name;
     $add_photo->user_id = 1;
     $add_photo->save();
     //перемещаем в папку с фотографиями
     $photo->move($this->base_dir, $add_photo->name);
     //добавляем категорию к фотографии
     if ($category_id = $this->add_category()) {
         $add_photo->category()->attach($category_id);
     }
     //создаем превью
     $this->add_thumbnail($add_photo->name, $add_photo->preview_url);
     return;
 }