hasFile() public static method

Determine if the uploaded data contains a file.
public static hasFile ( string $key ) : boolean
$key string
return boolean
 public function record()
 {
     if (\Request::hasFile('image') && \Request::file('image')->isValid() && \Auth::user()->suspend == false) {
         $file = \Request::file('image');
         $input = \Request::all();
         $date = new \DateTime();
         if (isset($input['anon'])) {
             $name = 'anon';
         } else {
             $name = \Auth::user()->name;
         }
         $validator = \Validator::make(array('image' => $file, 'category' => $input['category'], 'title' => $input['title'], 'caption' => $input['caption']), array('image' => 'required|max:1200|mimes:jpeg,jpg,gif', 'category' => 'required', 'title' => 'required|max:120', 'caption' => 'required|max:360'));
         if ($validator->fails()) {
             return redirect('/publish')->withErrors($validator);
         } else {
             $unique = str_random(10);
             $fileName = $unique;
             $destinationPath = 'database/pictures/stream_' . $input['category'] . '/';
             \Request::file('image')->move($destinationPath, $fileName);
             \DB::insert('insert into public.moderation (p_cat, p_ouser, p_title, p_caption, p_imgurl, p_status, p_reported, p_rating, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [$input['category'], $name, $input['title'], $input['caption'], $unique, 'available', 0, 0, $date, $date]);
             $messages = 'Your content has been succesfully submitted. Going on moderation process.';
             return redirect('/system/notification')->with('messages', $messages);
         }
     } else {
         $messages = 'Your content data is invalid. The process is aborted.';
         return redirect('/system/notification')->with('messages', $messages);
     }
 }
 public function editRecord()
 {
     $name = \Auth::user()->name;
     if (\Request::hasFile('avatar') && \Request::file('avatar')->isValid()) {
         $file = \Request::file('avatar');
         $input = \Request::all();
         $validator = \Validator::make(array('avatar' => $file, 'bio' => $input['bio']), array('avatar' => 'max:800|mimes:jpeg,jpg,gif', 'bio' => 'max:1000'));
         if ($validator->fails()) {
             return redirect('/profile/edit')->withErrors($validator);
         } else {
             if ($input['avatar_path'] == '0') {
                 $unique = str_random(20);
                 $fileName = $unique;
             } else {
                 $fileName = $input['avatar_path'];
             }
             $destinationPath = 'database/pictures/avatars/';
             \Request::file('avatar')->move($destinationPath, $fileName);
             \DB::table('users_data')->where('name', $name)->update(['bio' => $input['bio'], 'avatar' => $fileName]);
             return redirect('/profile/' . $name);
         }
     } else {
         $input = \Request::all();
         $validator = \Validator::make(array('bio' => $input['bio']), array('bio' => 'max:1000'));
         if ($validator->fails()) {
             return redirect('/profile/edit')->withErrors($validator);
         } else {
             \DB::table('users_data')->where('name', $name)->update(['bio' => $input['bio']]);
             return redirect('/profile/' . $name);
         }
     }
 }
Example #3
0
 public function postStore(UsersRequest $request = null, $id = "")
 {
     $input = $request->except('save_continue', 'password_confirmation');
     $result = '';
     if (\Request::hasFile('image')) {
         $photo = (new \ImageUpload($input))->upload();
     }
     if ($id == "") {
         $input['image'] = isset($photo) ? $photo : "";
         $input['password'] = bcrypt($input['password']);
         $query = $this->model->create($input);
         $result = $query->id;
     } else {
         if (\Request::hasFile('image')) {
             $input['image'] = isset($photo) ? $photo : "";
         }
         if (isset($input['password']) && $input['password'] != "") {
             $input['password'] = bcrypt($input['password']);
         }
         $this->model->find($id)->update($input);
         $result = $id;
     }
     $save_continue = \Request::get('save_continue');
     $redirect = empty($save_continue) ? $this->url : $this->url . '/edit/' . $result;
     return redirect($redirect)->with('message', 'Berhasil tambah data Pengguna!');
 }
Example #4
0
 public static function upload(Request $request, $tipo, $registroTabela)
 {
     // A VARIÁVEL $nomeTipo CONTÉM O NOME DO TIPO DA MIDIA E SERÁ USADA COMO NOME DA PASTA DENTRO DA PASTA UPLOADS
     $nomeTipo = TipoMidia::findOrFail($tipo)->descricao;
     // CRIANDO O REGISTRO PAI NA TABELA MIDIA
     $midia = new Midia();
     $midia->id_tipo_midia = $tipo;
     $midia->id_registro_tabela = $registroTabela;
     $midia->descricao = $nomeTipo . ' criado automaticamente com o banner';
     $midia->save();
     // FAZENDO O UPLOAD E GRAVANDO NA TABELA MULTIMIDIA
     #foreach ($request-> as $img) :
     // VERIFICANDO SE O ARQUIVO NÃO ESTÁ CORROMPIDO
     if ($request->hasFile('imagens')) {
         // PEGANDO O NOME ORIGINAL DO ARQUIVO A SER UPADO
         $nomeOriginal = $request->file('imagem')->getClientOriginalName();
         // MONTANDO O NOVO NOME COM MD5 + IDUNICO BASEADO NO NOME ORIGINAL E CONCATENANDO COM A EXTENÇÃO DO ARQUIVO
         $novoNome = md5(uniqid($nomeOriginal)) . '.' . $request->file('imagem')->getClientOriginalExtension();
         // MOVENDO O ARQUIVO PARA A PASTA UPLOADS/"TIPO DA MIDIA"
         $request->file('imagem')->move('uploads/' . $nomeTipo, $novoNome);
         // GRAVANDO NA TABELA MULTIMIDIA
         $imagem = new Multimidia();
         // PREPARANDO DADOS PARA GRAVAR NA TABELA MULTIMIDIA
         $imagem->id_midia = $midia->id_midia;
         $imagem->imagem = $novoNome or '';
         $imagem->descricao = $request->descricao or '';
         $imagem->link = $request->link or '';
         $imagem->ordem = $request->ordem or '';
         $imagem->video = $request->video or '';
         $imagem->save();
     }
     #endforeach;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $s3 = AWS::get('s3');
     $s3Bucket = 'buildbrighton-bbms';
     if (Request::hasFile('image')) {
         $file = Request::file('image');
         $event = Request::get('textevent');
         $time = Request::get('time');
         $fileData = Image::make($file)->encode('jpg', 80);
         $date = Carbon::createFromFormat('YmdHis', $event);
         $folderName = $date->hour . ':' . $date->minute . ':' . $date->second;
         try {
             $newFilename = \App::environment() . '/cctv/' . $date->year . '/' . $date->month . '/' . $date->day . '/' . $folderName . '/' . $time . '.jpg';
             $s3->putObject(array('Bucket' => $s3Bucket, 'Key' => $newFilename, 'Body' => $fileData, 'ACL' => 'public-read', 'ContentType' => 'image/jpg', 'ServerSideEncryption' => 'AES256'));
         } catch (\Exception $e) {
             \Log::exception($e);
         }
         //Log::debug('Image saved :https://s3-eu-west-1.amazonaws.com/buildbrighton-bbms/'.$newFilename);
     }
     if (Request::get('eventend') == 'true') {
         $event = Request::get('textevent');
         $date = Carbon::createFromFormat('YmdHis', $event);
         $folderName = $date->hour . ':' . $date->minute . ':' . $date->second;
         $iterator = $s3->getIterator('ListObjects', array('Bucket' => $s3Bucket, 'Prefix' => \App::environment() . '/cctv/' . $date->year . '/' . $date->month . '/' . $date->day . '/' . $folderName));
         $images = [];
         $imageDurations = [];
         foreach ($iterator as $object) {
             $images[] = 'https://s3-eu-west-1.amazonaws.com/buildbrighton-bbms/' . $object['Key'];
             $imageDurations[] = 35;
         }
         if (count($images) <= 2) {
             //only two images, probably two bad frames
             //delete them
             foreach ($iterator as $object) {
                 Log::debug("Deleting small event image " . $object['Key']);
                 $s3->deleteObject(['Bucket' => $s3Bucket, 'Key' => $object['Key']]);
             }
             return;
         }
         $gc = new GifCreator();
         $gc->create($images, $imageDurations, 0);
         $gifBinary = $gc->getGif();
         //Delete the individual frames now we have the gif
         foreach ($iterator as $object) {
             //Log::debug("Processed gif, deleting frame, ".$object['Key']);
             $s3->deleteObject(['Bucket' => $s3Bucket, 'Key' => $object['Key']]);
         }
         //Save the gif
         $newFilename = \App::environment() . '/cctv/' . $date->year . '/' . $date->month . '/' . $date->day . '/' . $folderName . '.gif';
         $s3->putObject(array('Bucket' => $s3Bucket, 'Key' => $newFilename, 'Body' => $gifBinary, 'ACL' => 'public-read', 'ContentType' => 'image/gif', 'ServerSideEncryption' => 'AES256'));
         //Log::debug('Event Gif generated :https://s3-eu-west-1.amazonaws.com/buildbrighton-bbms/'.$newFilename);
         \Slack::to("#cctv")->attach(['image_url' => 'https://s3-eu-west-1.amazonaws.com/buildbrighton-bbms/' . $newFilename, 'color' => 'warning'])->send('Movement detected');
     }
 }
 public function postUpdateProduct()
 {
     $input = \Request::all();
     $id = $input['id'];
     $update_array = ["product_name" => $input['product_name'], "count" => $input['count'], "buy_cost" => $input['buy_cost'], "sell_cost" => $input['sell_cost'], "desc" => $input['desc'], "cate" => $input['cate']];
     if (\Request::hasFile("product_img")) {
         //            dd($input);
         $img_save_path = real_imgs_dir . "selling-manager";
         $product_img_name = $this->upload_file(\Request::file("product_img"), $img_save_path);
         $update_array["product_img"] = $product_img_name;
     }
     \Selling_Manager_Products_Model::find($id)->update($update_array);
     return \Redirect::back();
 }
Example #7
0
 /**
  * Ajax serving
  */
 public function uploadBg()
 {
     $error = json_encode(['response' => 0, 'message' => trans('photo.error', ['size' => formatBytes()])]);
     if (\Request::hasFile('image')) {
         if (!$this->photoRepository->imagesMetSizes(\Input::file('image'))) {
             return $error;
         }
         if ($image = $this->userRepository->changeDesignBg(\Input::file('image'), \Input::get('val.bg_image'))) {
             return json_encode(['response' => 1, 'image' => \Image::url($image), 'imagePath' => $image]);
         } else {
             return $error;
         }
     }
     return $error;
 }
 /**
  * From ajax
  */
 public function savePhoto()
 {
     $response = ['code' => 0, 'message' => trans('photo.error', ['size' => formatBytes()]), 'url' => ''];
     if (\Request::hasFile('image')) {
         if (!$this->photoRepository->imagesMetSizes(\Input::file('image'))) {
             return json_encode($response);
         }
         $user = $this->userRepository->changeAvatar(\Input::file('image'));
         if ($user) {
             $response['code'] = 1;
             $response['url'] = $user->present()->getAvatar(100);
         }
     }
     return json_encode($response);
 }
Example #9
0
 public function upload()
 {
     if (\Request::hasFile('file')) {
         $file = \Request::file('file');
         if ($file instanceof UploadedFile) {
             $crud_file = CrudFile::createFromUpload($file);
             $ret = ['id' => $crud_file->id, 'url' => $crud_file->getDownloadLinkAttribute()];
             if (strpos($crud_file->mime_type, 'image') !== false) {
                 $dimensions = getimagesize($crud_file->path);
                 $ret['width'] = $dimensions[0];
                 $ret['height'] = $dimensions[1];
             }
             return $ret;
         }
     }
 }
function insertProcess()
{
    $send = Request::get('send');
    $valid = Validator::make(array('send.title' => 'required|min:1|slashes', 'send.parentid' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    if (Request::hasFile('image')) {
        if (Request::isImage('image')) {
            $send['image'] = File::upload('image');
        }
    }
    if (!($id = Categories::insert($send))) {
        throw new Exception("Error. " . Database::$error);
    }
}
Example #11
0
 public function changePhoto()
 {
     $id = \Input::get('id');
     $game = $this->gameRepository->get($id);
     $response = ['code' => 0, 'message' => trans('photo.error', ['size' => formatBytes()]), 'url' => ''];
     if (\Request::hasFile('image')) {
         if (!$this->photoRepository->imagesMetSizes(\Input::file('image'))) {
             return json_encode($response);
         }
         $image = $this->gameRepository->changePhoto(\Input::file('image'), $game);
         if ($image) {
             $response['code'] = 1;
             $response['url'] = \Image::url($image, 100);
         }
     }
     return json_encode($response);
 }
Example #12
0
 public function add()
 {
     if (\Request::all()) {
         $validator = \Validator::make(\Request::all(), ['email' => array('required', 'unique:users,email'), 'name' => 'required', 'password' => array('required', 'confirmed'), 'password_confirmation' => array('required'), 'role' => 'required', 'status' => 'required']);
         if ($validator->fails()) {
             return \Redirect::route('user/add')->withErrors($validator)->withInput();
         } else {
             //dd(\Request::all());
             $item = new User();
             if (\Request::hasFile('logo')) {
                 $dir = '/uploads/users' . date('/Y/' . $item->id . '/');
                 $filename = 'logo' . '.jpg';
                 //var_dump($dir);
                 //die();
                 $image = \Request::file('logo');
                 $image->move(storage_path() . $dir, $filename);
                 //$img = Image::make(storage_path().$dir.$filename);
                 //$img->resize(140, 180);
                 //$img->insert(public_path().'/template_image/watermark.png');
                 //$img->save(public_path().$dir.'thumb_'.$filename);
                 $item->logo = $dir . 'thumb_' . $filename;
                 //$item->save();
             }
             $item->name = \Request::get('name');
             $item->email = \Request::get('email');
             $item->name = \Request::get('name');
             $item->password = \Hash::make(\Request::get('password'));
             $item->phone = \Request::get('phone');
             $item->description = \Request::get('description');
             $item->status = \Request::get('status');
             $item->role = \Request::get('role');
             $item->link = Helper::alias(\Request::get('name'));
             $item->keywords = \Request::get('keywords');
             $item->save();
             return \Redirect::route('user/index');
         }
     }
     return view('abadmin::user.add');
 }
Example #13
0
 public function postStoreProfil($id, Request $request)
 {
     $input = $request->all();
     $rules = array('fullname' => 'required', 'image' => '', 'password' => 'min:6|confirmed', 'password_confirmation' => 'min:6');
     if (\Request::hasFile('image')) {
         $photo = (new \ImageUpload($input))->upload();
     }
     $validator = \Validator::make(\Request::all(), $rules);
     if ($validator->passes()) {
         $data = ['fullname' => $input['fullname']];
         if (!empty($input['password'])) {
             $data = ['password' => bcrypt($input['password'])];
         }
         if (\Request::hasFile('image')) {
             $data = ['image' => isset($photo) ? $photo : ""];
         }
         $this->model->find($id)->update($data);
         return \Redirect::back()->with('message', 'Sukses Ubah Data Profil!')->withInput(\Request::all());
     } else {
         return redirect($this->url . "/profil")->withErrors($validator);
     }
 }
 public function store(Request $request)
 {
     if ($request->hasFile('files')) {
         $file = $request->file('files');
         foreach ($file as $files) {
             $filename = $files->getClientOriginalName();
             $extension = $files->getClientOriginalExtension();
             $picture = sha1($filename . time()) . '.' . $extension;
             $folder = project::select('folder')->where('id', session('progetto'))->get();
             //specify your folder
             $destinationPath = public_path() . '/files_clients/' . $folder[0]->folder . '/';
             $files->move($destinationPath, $picture);
             $destinationPath1 = 'http://' . $_SERVER['HTTP_HOST'] . '/files_clients/' . $folder[0]->folder . '/';
             $filest = array();
             $filest['name'] = $picture;
             $filest['size'] = $this->get_file_size($destinationPath . $picture);
             $filest['url'] = $destinationPath1 . $picture;
             $filest['thumbnailUrl'] = $destinationPath1 . $picture;
             $filesa['files'][] = $filest;
         }
         return $filesa;
     }
 }
Example #15
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // create the validator
     $validator = Validator::make(Input::all(), Post::$rules);
     // attempt validation
     if ($validator->fails()) {
         Session::flash('errorMessage', 'Something went wrong.');
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         $post = new Post();
         $title = Input::get('title');
         $body = Input::get('body');
         if (Request::hasFile('file')) {
             $img = Imageupload::upload(Request::file('file'));
             $post->img_url = $img['filename'];
         }
         $post->title = $title;
         $post->body = $body;
         $post->user_id = Auth::id();
         $post->save();
         $post_id = $post->id;
         $tags = Input::get('tags');
         if (isset($tags)) {
             $tags = strtolower(Input::get('tags'));
             $tags = explode(', ', $tags);
             foreach ($tags as $tag) {
                 $tag = trim($tag);
                 $tag_id = Tag::firstOrCreate(array('name' => $tag));
                 $post->tags()->attach($tag_id, array('post_id' => $post_id));
             }
         }
         Log::info('Success: ', ['title' => $post->title, 'body' => $post->body]);
         Session::flash('successMessage', 'You created a post successfully');
         return Redirect::action('PostsController@index');
     }
 }
 public function postStore(NewsletterRequest $request = null, $id = "")
 {
     $input = $request->except('save_continue');
     $result = '';
     if (\Request::hasFile('image')) {
         $photo = (new \ImageUpload($input, 480, 270))->upload();
     }
     if ($id == "") {
         $input['slug'] = str_slug($input['title'], "-");
         $input['image'] = isset($photo) ? $photo : "";
         $query = $this->model->create($input);
         $result = $query->id;
     } else {
         if (\Request::hasFile('image')) {
             $input['image'] = isset($photo) ? $photo : "";
         }
         $input['slug'] = str_slug($input['title'], "-");
         $this->model->find($id)->update($input);
         $result = $id;
     }
     $save_continue = \Input::get('save_continue');
     $redirect = empty($save_continue) ? $this->url : $this->url . '/edit/' . $result;
     return redirect($redirect)->with('message', 'Berhasil tambah data Newsletter!');
 }
Example #17
0
 public function changePhoto()
 {
     $id = \Input::get('id');
     $page = $this->pageRepository->get($id);
     $response = ['code' => 0, 'message' => trans('page.change-photo-fail'), 'url' => ''];
     if (\Request::hasFile('image')) {
         if (!$this->photo->imagesMetSizes(\Input::file('image'))) {
             return json_encode($response);
         }
         $image = $this->pageRepository->changePhoto(\Input::file('image'), $page);
         if ($image) {
             $response['code'] = 1;
             $response['url'] = \Image::url($image, 100);
         }
     }
     return json_encode($response);
 }
Example #18
0
//Route::group(['prefix' => 'API/'], function(){
//    $email = 'ggxx@gmail.com';
//    $password ='ggxx0926';
//
//    if(Auth::attempt)
//
//});
Route::get('API/getPhotosFrom({user})', ["as" => "API/all", function ($user) {
    return App\Models\Myuser::where('users_name', '=', $user)->photos()->get();
}]);
Route::post('API/fileUpLoadGo', function () {
    //       $file = Request::input('user_file');
    //              $fileName = \Carbon\Carbon::now().".".Request::file('user_file')->getClientOriginalExtension();//將檔名變成上傳時間now()
    //            $fileName =str_replace(":","-",$fileName);
    //            $fileName =str_replace(" ","-",$fileName);
    if (Request::hasFile('user_file')) {
        if (Request::file('user_file')->isValid()) {
            //               Request::file('user_file')->move(".",$fileName);//將上傳的檔案移到public資料牙
            $fileName = Request::file('user_file')->getRealPath();
            $image = Image::make($fileName)->encode('jpg', 100);
            //將圖片轉譯存入變數image
            $datas = \App\Models\Data::find(1);
            $datas->data = $image;
            $datas->save();
            //           return view('fileUploadSucces',['user_file'=>$fileName]);//上傳的圖片顯示在網頁
            $datas = \APP\Models\Data::find(1);
            $response = Response::make($datas->data, 200);
            $response->header('Content-Type', 'image/jpeg');
            //設定網頁資料格式
            return $response;
        } else {
Example #19
0
<?php

/**
 * Created by PhpStorm.
 * User: skinux
 * Date: 5/6/15
 * Time: 1:21 PM
 */
$hasDemographics = \Input::hasFile('demographics');
$hasRates = \Request::hasFile('rates');
$advertising = \Advertising::first();
dd($hasDemographics . $hasRates);
if ($hasDemographics || $hasRates) {
    $demographics_uploaded = false;
    $rates_uploaded = false;
    $destination = public_path() . "/advertising/";
    if (!$advertising) {
        $advertising = \Advertising::create(\Input::only(['demographics', 'rates']));
    }
    if ($hasDemographics) {
        if (\Input::file('demographics')->isValid()) {
            $demographics = \Input::file('demographics')->getClientOriginalName();
            $demographics_uploaded = \Request::file('demographics')->move($destination, $demographics);
            dd($demographics_uploaded);
            /* $uploadedDemographics = $advertising->save();
               if ($demographics_success && $uploadedDemographics) {
                   $savedDemographics = true;
               } */
        }
    }
    if ($hasRates) {
Example #20
0
 function rqFile($name)
 {
     if (!Request::hasFile($name)) {
         return false;
     }
     return Request::file($name);
 }
Example #21
0
function insertProcess()
{
    $send = Request::get('send');
    $valid = Validator::make(array('send.title' => 'min:1|slashes', 'send.content' => 'min:1', 'send.keywords' => 'slashes', 'send.page_type' => 'slashes', 'send.allowcomment' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    $friendlyUrl = trim(String::makeFriendlyUrl($send['title']));
    $getData = Pages::get(array('where' => "where friendly_url='{$friendlyUrl}'"));
    if (isset($getData[0]['pageid'])) {
        throw new Exception("This page exists in database.");
    }
    $uploadMethod = Request::get('uploadMethod');
    switch ($uploadMethod) {
        case 'frompc':
            if (Request::hasFile('imageFromPC')) {
                if (Request::isImage('imageFromPC')) {
                    $send['image'] = File::upload('imageFromPC');
                }
            }
            break;
        case 'fromurl':
            if (Request::isImage('imageFromUrl')) {
                $url = Request::get('imageFromUrl');
                $send['image'] = File::upload('uploadFromUrl');
            }
            break;
    }
    if (!($id = Pages::insert($send))) {
        throw new Exception("Error. " . Database::$error);
    }
}
Example #22
0
});
Route::get('noticias/{slug}', 'NoticiasController@show');
Route::get('noticias/{id}/imagen', 'NoticiasController@Imagen');
Route::get('bolsa-de-trabajo', function () {
    $puestos = ['Odontólogo/a', 'Administrativo/a', 'Técnico/a', 'Recepcionista', 'Otros'];
    $provincias = json_decode('[{"state":"Capital Federal","country":"Argentina"},{"state":"Buenos Aires","country":"Argentina"},{"state":"Catamarca","country":"Argentina"},{"state":"Chaco","country":"Argentina"},{"state":"Chubut","country":"Argentina"},{"state":"Cordoba","country":"Argentina"},{"state":"Corrientes","country":"Argentina"},{"state":"Entre Rios","country":"Argentina"},{"state":"Formosa","country":"Argentina"},{"state":"Jujuy","country":"Argentina"},{"state":"La Pampa","country":"Argentina"},{"state":"La Rioja","country":"Argentina"},{"state":"Mendoza","country":"Argentina"},{"state":"Misiones","country":"Argentina"},{"state":"Neuquen","country":"Argentina"},{"state":"Rio Negro","country":"Argentina"},{"state":"Salta","country":"Argentina"},{"state":"San Juan","country":"Argentina"},{"state":"San Luis","country":"Argentina"},{"state":"Santa Cruz","country":"Argentina"},{"state":"Santa Fe","country":"Argentina"},{"state":"Santiago del Estero","country":"Argentina"},{"state":"Tierra del Fuego","country":"Argentina"},{"state":"Tucuman","country":"Argentina"}]');
    return view('bolsa', ["provincias" => $provincias, "puestos" => $puestos, "mensaje" => false]);
});
Route::post('bolsa-de-trabajo', function () {
    $data = Input::all();
    $validator = Validator::make(Input::all(), ['nombre' => 'required|max:255', 'apellido' => 'required|max:255', 'dni' => 'required|numeric', 'fecha_nacimiento' => 'required|date', 'puesto' => 'required|max:255', 'domicilio' => 'required|max:255', 'localidad' => 'required|max:255', 'provincia' => 'required|max:255', 'telefono' => 'required|max:255', 'celular' => 'required|max:255', 'email' => 'required|email', 'linkedin' => 'required|url']);
    if ($validator->fails()) {
        return redirect('bolsa-de-trabajo')->withErrors($validator)->withInput();
    }
    $cv = App\Curriculum::create($data);
    if (Request::hasFile('cv')) {
        $arch = Request::file('cv');
        Storage::put('curriculums/' . $cv->id . '.' . $arch->getClientOriginalExtension(), File::get($arch));
    }
    return view('bolsa', ["mensaje" => true]);
});
Route::group(['middleware' => 'auth'], function () {
    Route::resource('bolsa-de-trabajo/consulta', 'BolsaDeTrabajoController', ['only' => ['index', 'show']]);
    Route::get('curriculum/{id}/descargar', function ($id) {
        $cv = App\Curriculum::findOrFail($id);
        $mimetype = array('pdf' => 'application/pdf', 'doc' => 'Content-Type: application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
        $content = NULL;
        $mime = NULL;
        $nombre = NULL;
        foreach ($mimetype as $ext => $type) {
            if (Storage::has('curriculums/' . $cv->id . "." . $ext)) {
Example #23
0
 private function saveRecipe(Recipe $recipe)
 {
     $input = Input::only('title', 'people', 'presentation', 'year', 'season', 'cookbook', 'category', 'temperature', 'visibility', 'tracking_nr');
     $recipe->fill($input);
     if (empty($recipe->tracking_nr)) {
         $recipe->tracking_nr = $this->db->table('recipes')->max('tracking_nr') + 1;
     }
     if (Input::has('lang')) {
         $recipe->language = Input::get('lang');
     }
     if (Input::has('directions')) {
         $recipe->description = Input::get('directions');
     }
     // Override the category if the user provided one.
     if (!empty(Input::get('category_alt'))) {
         $recipe->category = Input::get('category_alt');
     }
     try {
         $recipe_saved = $recipe->save();
     } catch (QueryException $e) {
         $recipe->tracking_nr = $this->db->table('recipes')->max('tracking_nr') + 1;
         $recipe_saved = $recipe->save();
         Session::flash('warning', 'Let op: je recept is onder een nieuw volgnummer bewaard, omdat het opgegeven nummer al in gebruik was.');
     }
     if (RequestFacade::hasFile('picture')) {
         $path = join(DIRECTORY_SEPARATOR, [public_path(), 'uploads', 'pictures']);
         $filename = $recipe->tracking_nr . '.jpg';
         $file = RequestFacade::file('picture')->move($path, $filename);
         $image = Image::make($file)->widen(480);
         $image->save($path . DIRECTORY_SEPARATOR . $filename);
     }
     $ingredients_saved = $recipe->saveIngredientsFromText(Input::get('ingredients'));
     if ($recipe_saved && $ingredients_saved) {
         return redirect()->route('recipes.show', ['recipes' => $recipe->tracking_nr])->with('lang', $recipe->language);
     } else {
         abort(500);
     }
 }
 /**
  * Upload & Resize the file from \File or url
  * @param string $type 
  * @param string $input 
  * @param string $name 
  * @param array|null $crop 
  * @param array|null $rotate 
  * @return ImageFile instance
  */
 public function upload($type, $input, $name, $crop = null, $rotate = null, $override_config = [])
 {
     if (strlen($name) > 255) {
         throw new \TarunMangukiya\ImageResizer\Exception\TooLongFileNameException("Error Processing Request", 1);
     }
     // Get Config for the current Image type
     $type_config = ImageResizerConfig::getTypeConfig($type, $override_config);
     $crop_enabled = $type_config['crop']['enabled'];
     // Get the original save location according to config
     if ($crop_enabled && null !== $crop) {
         $original_location = array_key_exists('uncropped_image', $type_config['crop']) ? $type_config['crop']['uncropped_image'] : $type_config['original'];
     } else {
         $original_location = $type_config['original'];
     }
     // Check input type is $_FILES input name or local file or url
     // Check for Input File
     if (\Request::hasFile($input)) {
         $original_file = $this->moveUploadedFile($input, $name, $original_location);
     } elseif (file_exists($input)) {
         $original_file = $this->copyFile($input, $name, $original_location);
     } elseif (filter_var($input, FILTER_VALIDATE_URL) !== FALSE) {
         $original_file = $this->transferURLFile($input, $name, $original_location);
     } else {
         throw new \TarunMangukiya\ImageResizer\Exception\InvalidInputException("Invalid Input for Image Resizer.");
     }
     // crop the image if enabled
     if ($crop_enabled && null !== $crop) {
         $file = $this->transformImage($original_file, $type_config, $crop, $rotate);
     } else {
         $file = $original_file;
     }
     // Check if there is no resize of files
     if (count($type_config['sizes'])) {
         $job = new ResizeImages($file, $type_config);
         // Check if we have to queue the resize of the image
         if ($this->config['queue']) {
             \Queue::pushOn($this->config['queue_name'], $job);
         } else {
             $job->handle();
         }
     }
     return $file;
 }
Example #25
0
function insertProcess()
{
    $send = Request::get('send');
    $valid = Validator::make(array('send.title' => 'min:1|slashes', 'send.keywords' => 'slashes', 'tags' => 'slashes', 'send.catid' => 'slashes', 'send.type' => 'slashes', 'send.allowcomment' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    $friendlyUrl = trim(String::makeFriendlyUrl($send['title']));
    $getData = Post::get(array('where' => "where friendly_url='{$friendlyUrl}'"));
    if (isset($getData[0]['postid'])) {
        throw new Exception("This post exists in database.");
    }
    $uploadMethod = Request::get('uploadMethod');
    switch ($uploadMethod) {
        case 'frompc':
            if (Request::hasFile('imageFromPC')) {
                if (Request::isImage('imageFromPC')) {
                    $send['image'] = File::upload('imageFromPC');
                }
            }
            break;
        case 'fromurl':
            if (Request::isImage('imageFromUrl')) {
                $url = Request::get('imageFromUrl');
                $send['image'] = File::upload('uploadFromUrl');
            }
            break;
    }
    $send['userid'] = Users::getCookieUserId();
    if (!Request::has('send.catid')) {
        $loadCat = Categories::get(array('limitShow' => 1));
        if (isset($loadCat[0]['catid'])) {
            $send['catid'] = $loadCat[0]['catid'];
        }
    }
    if (!($id = Post::insert($send))) {
        throw new Exception("Error. " . Database::$error);
    }
    $tags = trim(Request::get('tags'));
    $parse = explode(',', $tags);
    $total = count($parse);
    $insertData = array();
    for ($i = 0; $i < $total; $i++) {
        $insertData[$i]['title'] = trim($parse[$i]);
        $insertData[$i]['postid'] = $id;
    }
    PostTags::insert($insertData);
}
Example #26
0
 public function postAdd()
 {
     $data = Input::all();
     $validation = Validator::make($data, Poster::getValidationRules());
     if ($validation->fails()) {
         return View::make('message', array('OKs' => [], 'errors' => $validation->errors()->all()));
     }
     $image_dir = 'images/';
     $image_sml_name = "no_image_sml.jpg";
     $image_name = "no_image.jpg";
     if (Request::hasFile('image')) {
         $image = Request::file('image');
         $image_name = time() . $image->getBasename();
         $image->move($image_dir, $image_name);
     }
     $data['image_sml'] = $image_dir . $image_sml_name;
     $data['image'] = $image_dir . $image_name;
     $data['author_ip'] = $this->getIP();
     $data['author_browser'] = $_SERVER['HTTP_USER_AGENT'];
     $data['author_country'] = "Ukraine";
     Poster::create($data);
     return View::make('message', array('OKs' => ['Poster created'], 'errors' => ['']));
     /*$data = Input::all();
     
             $validation = Validator::make($data, Poster::getValidationRules());
             if ($validation->fails()) {
                 return View::make('message', array('OKs' => [], 'errors' => $validation->errors()->all()));
             }
             $image_sml = "images/no_image_sml.jpg";
             $image = "images/no_image.jpg";
             if (!empty($_FILES['image']['name'])) {
                 $date = time();
                 Input::upload('image', 'images', $date.$_FILES['image']['name']);
     
                 if (preg_match('/[.](JPG)|(jpg)|(jpeg)|(JPEG)|(gif)|(GIF)|(png)|(PNG)$/', $_FILES['image']['name'])) {
                     $filename = $_FILES['image']['name'];
                     $source = $_FILES['image']['tmp_name'];
                     $image = $path_directory . $date . $filename;
                     move_uploaded_file($source, $image);
                     $im = null;
                     if (preg_match('/[.](GIF)|(gif)$/', $filename)) $im = imagecreatefromgif($image);
                     if (preg_match('/[.](PNG)|(png)$/', $filename)) $im = imagecreatefrompng($image);
                     if (preg_match('/[.](JPG)|(jpg)|(jpeg)|(JPEG)$/', $filename)) $im = imagecreatefromjpeg($image);
                     $w = 100;
                     $w_src = imagesx($im);
                     $h_src = imagesy($im);
                     $dest = imagecreatetruecolor($w, $w);
                     if ($w_src > $h_src)
                         imagecopyresampled($dest, $im, 0, 0,
                             round((max($w_src, $h_src) - min($w_src, $h_src)) / 2),
                             0, $w, $w, min($w_src, $h_src), min($w_src, $h_src));
                     if ($w_src < $h_src)
                         imagecopyresampled($dest, $im, 0, 0, 0, 0, $w, $w,
                             min($w_src, $h_src), min($w_src, $h_src));
                     if ($w_src == $h_src)
                         imagecopyresampled($dest, $im, 0, 0, 0, 0, $w, $w, $w_src, $w_src);
                     imagejpeg($dest, $path_directory . $date . ".jpg");
                     $image_sml = $path_directory . $date . ".jpg";
                 } else return View::make('message', array('OKs' => [], 'errors' => ["Not correct image file"]));
             }
             $data['image_sml'] = $image_sml;
             $data['image'] = $image;
             $data['author_ip'] = $this->getIP();
             $data['author_browser'] = $_SERVER['HTTP_USER_AGENT'];
             $data['author_country'] = "Ukraine";
             Poster::create($data);
             return View::make('message', array('OKs' => ['Poster created'], 'errors' => ['']));*/
 }
<?php

Route::any('matriphe/imageupload', function () {
    $data = [];
    echo config('imageupload.library');
    if (Request::hasFile('file')) {
        $data['result'] = Imageupload::upload(Request::file('file'));
    }
    return view('imageupload::form')->with($data);
});
Example #28
0
 public static function process($modelConfig, $imageFields, $parentProperty)
 {
     $imageData = array();
     $counter = 0;
     foreach ($imageFields as $imageField) {
         $imageData[$counter]['property'] = $imageField->property;
         if (\Request::hasFile($imageField->property)) {
             $ext = \Request::file($imageField->property)->getClientOriginalExtension();
             if (!in_array(strtolower($ext), array('jpg', 'jpeg', 'gif', 'png'))) {
                 throw new \Exception("File is not an image");
             } else {
                 $basePath = public_path() . "/img/modelImages/" . $modelConfig->name . "/";
                 $dirs = [public_path("img"), public_path("img/modelImages"), public_path("img/modelImages/" . $modelConfig->name), public_path("img/modelImages/" . $modelConfig->name . "/original"), public_path("img/modelImages/" . $modelConfig->name . "/gtcmsThumb")];
                 foreach ($dirs as $dir) {
                     if (!is_dir($dir)) {
                         mkdir($dir, 0755);
                     }
                 }
                 //here check if file exists
                 do {
                     $name = str_random(32) . "." . $ext;
                 } while (file_exists($basePath . "original/" . $name));
                 //end check
                 //copy the image to the original folder
                 \Image::make(\Request::file($imageField->property)->getRealPath())->save($basePath . "original/" . $name);
                 $img = \Image::make($basePath . "original/" . $name);
                 if ($parentProperty && $modelConfig->name == 'ModelImage') {
                     $parentModelConfig = AdminHelper::modelExists($parentProperty, 'id');
                     if (config('gtcms.premium') && $parentModelConfig->keyBasedSizes) {
                         $sizes = GtcmsPremium::getKeyBasedImageSizes($parentModelConfig);
                     } else {
                         $sizes = $parentModelConfig->imageSizes;
                     }
                 } else {
                     $sizes = $imageField->sizes;
                 }
                 if (!$sizes) {
                     throw new \Exception("Sizes not found!");
                 }
                 // Get the first size, which has the min/max dimensions
                 foreach ($sizes as $size) {
                     break;
                 }
                 $size = AdminHelper::objectToArray($size);
                 $minWidth = $size[0];
                 $minHeight = $size[1];
                 $transformMethod = $size[2];
                 if (in_array($transformMethod, array('resizeCanvas', 'resize'))) {
                     if ($img->width() < $minWidth && $img->height() < $minHeight) {
                         throw new \Exception(trans('gtcms.imageTooSmall'), self::DIM_ERROR);
                     }
                 }
                 if (in_array($transformMethod, array('minWidth'))) {
                     if ($img->width() < $minWidth) {
                         throw new \Exception(trans('gtcms.imageTooSmall'), self::DIM_ERROR);
                     }
                 }
                 if (in_array($transformMethod, array('minHeight'))) {
                     if ($img->height() < $minHeight) {
                         throw new \Exception(trans('gtcms.imageTooSmall'), self::DIM_ERROR);
                     }
                 } else {
                     if ($img->width() < $minWidth || $img->height() < $minHeight) {
                         throw new \Exception(trans('gtcms.imageTooSmall'), self::DIM_ERROR);
                     }
                 }
                 $returnFolder = 'gtcmsThumb';
                 $gtcmsSize = array(80, 80, 'resizeCanvas', 'gtcmsThumb', 100);
                 $sizes = AdminHelper::objectToArray($sizes);
                 array_unshift($sizes, $gtcmsSize);
                 foreach ($sizes as $size) {
                     $newImg = clone $img;
                     $size = AdminHelper::objectToArray($size);
                     if (!is_dir($basePath . $size[3])) {
                         mkdir($basePath . $size[3], 0755);
                     }
                     if ($size[2] == 'crop') {
                         $newImg->fit($size[0], $size[1])->save($basePath . $size[3] . "/" . $name, $size[4]);
                     } else {
                         if (in_array($size[2], array('resize', 'minWidth', 'minHeight'))) {
                             $newImg->resize($size[0], $size[1], function ($constraint) {
                                 $constraint->aspectRatio();
                                 $constraint->upsize();
                             })->save($basePath . $size[3] . "/" . $name, $size[4]);
                         } else {
                             if ($size[2] == 'resizeCanvas') {
                                 $newImg->resize($size[0], null, function ($constraint) {
                                     $constraint->aspectRatio();
                                     $constraint->upsize();
                                 });
                                 $newImg->resize(null, $size[1], function ($constraint) {
                                     $constraint->aspectRatio();
                                     $constraint->upsize();
                                 });
                                 if ($newImg->width() < $size[0] || $newImg->height() < $size[1]) {
                                     $newImg = \Image::canvas($size[0], $size[1], '#FFFFFF')->insert($newImg, 'center');
                                 }
                                 $newImg->save($basePath . $size[3] . "/" . $name, $size[4]);
                             } else {
                                 $newImg->save($basePath . $size[3] . "/" . $name, $size[4]);
                             }
                         }
                     }
                 }
                 $imageData[$counter]['filename'] = $name;
                 $imageData[$counter]['returnFolder'] = $returnFolder;
                 $counter++;
             }
         }
     }
     return $imageData;
 }