コード例 #1
0
 public function edit()
 {
     $petad_id = Input::get('petad-id');
     $all_inputs = Input::all();
     $files = Input::file('file');
     // setting up rules
     if (Input::hasFile('file')) {
         foreach ($files as $file) {
             $destinationPath = 'public/pb-uploads/pet_images/';
             // upload path
             $thumbnail_path = 'public/pb-uploads/pet_images_thumbnail/';
             $popibay_watermark = 'public/pb-uploads/pet_images/popibay_white_logo_watermark/popibay_watermark_logo.png';
             $popibay_watermark_new = 'public/pb-uploads/pet_images/popibay_white_logo_watermark/popibay_watermark_opacity_logo.png';
             $extension = $file->getClientOriginalExtension();
             // getting image extension
             $original_name = $file->getClientOriginalName();
             $random_number = rand(11111, 99999);
             $fileName = $random_number . '.' . $extension;
             // renaming image
             // Image::make($file)->resize(600, 357)->insert($popibay_watermark_new,'center')->save($destinationPath.$fileName);
             Image::make($file)->insert($popibay_watermark_new, 'center')->save($destinationPath . $fileName);
             Image::make($file)->resize(125, 155)->save($thumbnail_path . $fileName);
             // thumbnail image
             $domain = 'http://popibay.com';
             $destinationPath = '/pb-uploads/pet_images/';
             // upload path
             $thumbnail_path = '/pb-uploads/pet_images_thumbnail/';
             $temp_id = rand(1, 100);
             // save temp_id value to session...
             $temp_saved_id = Petimage::where('petad_id', '=', $petad_id)->first();
             $temp_saved_id = $temp_saved_id->temp_id;
             $saved_temp_id = $temp_saved_id;
             // if ( isset($saved_temp_id) ) {
             $pet_image = new Petimage();
             $pet_image->temp_id = $saved_temp_id;
             $pet_image->petad_id = $petad_id;
             $pet_image->original_name = $original_name;
             $pet_image->image_path = $domain . $destinationPath . $fileName;
             $pet_image->image_thumbnail_path = $domain . $thumbnail_path . $fileName;
             $pet_image->image_name = $fileName;
             $pet_image->save();
             Session::put('saved_temp_id', $saved_temp_id);
         }
     }
 }
コード例 #2
0
 public function edit()
 {
     // edit s3 file...
     $petad_id = Input::get('petad-id');
     $all_inputs = Input::all();
     $files = Input::file('file');
     // setting up rules
     if (Input::hasFile('file')) {
         foreach ($files as $file) {
             $destinationPath = 'public/pb-uploads/pet_images/';
             // upload path
             $thumbnail_path = 'public/pb-uploads/pet_images_thumbnail/';
             $popibay_watermark = 'public/pb-uploads/pet_images/popibay_white_logo_watermark/popibay_watermark_logo.png';
             $popibay_watermark_new = 'public/pb-uploads/pet_images/popibay_white_logo_watermark/popibay_watermark_opacity_logo.png';
             $extension = $file->getClientOriginalExtension();
             // getting image extension
             $original_name = $file->getClientOriginalName();
             $random_number = rand(11111, 99999);
             $fileName = $random_number . '.' . $extension;
             // renaming image
             // Image::make($file)->resize(600, 357)->insert($popibay_watermark_new,'center')->save($destinationPath.$fileName);
             Image::make($file)->insert($popibay_watermark_new, 'center')->save($destinationPath . $fileName);
             Image::make($file)->resize(125, 155)->save($thumbnail_path . $fileName);
             // thumbnail image
             $destinationPath_del = $destinationPath;
             $thumbnail_path_del = $thumbnail_path;
             $s3_url_domain = 'https://s3.amazonaws.com/';
             $s3_bucket = 'popibay-bucket-s3/';
             $s3_destination_path = 'popibay/pb-uploads/pet_images/' . $fileName;
             $s3_thumbnail_path = 'popibay/pb-uploads/pet_images_thumbnail/' . $fileName;
             $destination_path_to_s3 = 'pb-uploads/pet_images/';
             $thumbnail_path_to_s3 = 'pb-uploads/pet_images_thumbnail/';
             $s3_destination_path_db = $s3_bucket . 'popibay/pb-uploads/pet_images/';
             $s3_thumbnail_path_db = $s3_bucket . 'popibay/pb-uploads/pet_images_thumbnail/';
             $s3 = AWS::get('s3');
             $s3->putObject(array('Bucket' => 'popibay-bucket-s3', 'Key' => $s3_destination_path, 'Body' => $destination_path_to_s3 . $fileName));
             $s3 = AWS::get('s3');
             $s3->putObject(array('Bucket' => 'popibay-bucket-s3', 'Key' => $s3_thumbnail_path, 'Body' => $thumbnail_path_to_s3 . $fileName));
             $domain = $s3_url_domain;
             $destinationPath = $s3_destination_path_db;
             // upload path
             $thumbnail_path = $s3_thumbnail_path_db;
             // $domain = 'http://popibay.com';
             // $destinationPath = '/pb-uploads/pet_images/'; // upload path
             // $thumbnail_path = '/pb-uploads/pet_images_thumbnail/';
             $temp_id = rand(1, 100);
             // save temp_id value to session...
             $temp_saved_id = Petimage::where('petad_id', '=', $petad_id)->first();
             $temp_saved_id = $temp_saved_id->temp_id;
             $saved_temp_id = $temp_saved_id;
             // if ( isset($saved_temp_id) ) {
             $pet_image = new Petimage();
             $pet_image->temp_id = $saved_temp_id;
             $pet_image->petad_id = $petad_id;
             $pet_image->original_name = $original_name;
             $pet_image->image_path = $domain . $destinationPath . $fileName;
             $pet_image->image_thumbnail_path = $domain . $thumbnail_path . $fileName;
             $pet_image->image_name = $fileName;
             $pet_image->save();
             Session::put('saved_temp_id', $saved_temp_id);
             File::delete($destinationPath_del . $fileName);
             File::delete($thumbnail_path_del . $fileName);
         }
     }
 }