コード例 #1
0
ファイル: PostGestion.php プロジェクト: Reval63/projet_photo
 public function store()
 {
     $post = new Post();
     $post->titre = Request::get('titre');
     if (Request::has('description')) {
         $post->description = Request::get('description');
     } else {
         $post->description = 'No description for this picture';
     }
     $post->user_id = Request::get('user_id');
     $post->privacy = Request::get('privacy');
     $chemin = public_path() . '/images/' . $post->user_id;
     $image = Request::file('photo');
     if (!strcmp($image->getClientOriginalExtension(), 'tmp')) {
         $extension = 'jpg';
     } else {
         $extension = $image->getClientOriginalExtension();
     }
     do {
         $nom = Str::random(10) . '.' . $extension;
     } while (file_exists($chemin . '/' . $nom));
     $post->chemin = '/images/' . $post->user_id . '/' . $nom;
     $image->move($chemin, $nom);
     Image::make($chemin . '/' . $nom)->resize(200, 200)->save(resizedName($chemin . '/' . $nom, 200, 200));
     $post->save();
 }
コード例 #2
0
ファイル: UserGestion.php プロジェクト: Reval63/projet_photo
 public function avatar($id)
 {
     $image = Request::file('photo');
     $path = public_path() . '/avatar';
     $name = $id . '.jpg';
     if (file_exists($path . '/' . $name)) {
         unlink($path . '/' . $name);
         unlink(resizedName($path . '/' . $name, 200, 200));
     }
     $image->move($path, $name);
     Image::make($path . '/' . $name)->resize(200, 200)->save(resizedName($path . '/' . $name, 200, 200));
 }
コード例 #3
0
<?php

require ROOT . '/core/Image.php';
?>

<img src="<?php 
resizedName(IMAGE, 200, 200);
?>
" />