public function adAnnounce(Request $request) { $data = ["name" => $request->name, "email" => $request->email, "phone" => $request->phone, "description" => $request->description, "chambres" => $request->chambres, "pieces" => $request->pieces, "surface" => $request->surface, "prix" => $request->prix, "aid" => $request->aid]; $file = null; $data["email"] = $request->email; $input = array('image' => Input::file('image')); $rules = array('image' => 'image'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return response()->json(['data' => 'Fichier invalid', 'state' => false]); } else { if ($request->hasFile('image')) { $file = $request->file('image'); $filename = $file->getClientOriginalName(); $destinationPath = public_path() . '/uploads/ad'; $file->move($destinationPath, $filename); $data['image'] = asset('uploads/ad/' . $filename); $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017'); $collection = new \MongoDB\Collection($manager, 'builders', 'ads'); $stat = ['email' => $request->email, 'data' => $data, 'created' => new \DateTime("now")]; try { $collection->insertOne($stat); } catch (\Exception $e) { return response()->json(['state' => false]); } return response()->json(['data' => $data, 'state' => true]); } } }
public function postImport($id) { $report = \App\Models\Report::find($id); if (Input::hasFile('file')) { $file = Input::file('file'); $filename = $file->getClientOriginalName(); $destinationPath = public_path() . '/uploads/'; Input::file('file')->move($destinationPath, $filename); $handle = fopen(public_path() . '/uploads/' . $filename, "r"); if ($handle !== FALSE) { while (($data = fgetcsv($handle, 1000, ';')) !== FALSE) { $depreciation = new \App\Models\Depreciation(); $name = iconv("Windows-1251", "utf-8", $data[0]); $depreciation->name = $name; $depreciation->number = $data[1]; $carrying_amount = $data[2]; $carrying_amount = str_replace(",", ".", $carrying_amount); $carrying_amount = str_replace(" ", "", $carrying_amount); $depreciation->carrying_amount = $carrying_amount; $sum = $data[3]; $sum = str_replace(",", ".", $sum); $sum = str_replace(" ", "", $sum); $depreciation->sum = $sum; $residual_value = $data[4]; $residual_value = str_replace(",", ".", $residual_value); $residual_value = str_replace(" ", "", $residual_value); $depreciation->residual_value = $residual_value; $depreciation->report_id = $id; $depreciation->save(); } } } return redirect()->back(); }
/** * Upload the file and store * the file path in the DB. */ public function store() { // Rules $rules = array('name' => 'required', 'file' => 'required|max:20000'); $messages = array('max' => 'Please make sure the file size is not larger then 20MB'); // Create validation $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $directory = "uploads/files/"; // Before anything let's make sure a file was uploaded if (Input::hasFile('file') && Request::file('file')->isValid()) { $current_file = Input::file('file'); $filename = Auth::id() . '_' . $current_file->getClientOriginalName(); $current_file->move($directory, $filename); $file = new Upload(); $file->user_id = Auth::id(); $file->project_id = Input::get('project_id'); $file->name = Input::get('name'); $file->path = $directory . $filename; $file->save(); return Redirect::back(); } $upload = new Upload(); $upload->user_id = Auth::id(); $upload->project_id = Input::get('project_id'); $upload->name = Input::get('name'); $upload->path = $directory . $filename; $upload->save(); return Redirect::back(); }
public function excel(Request $request) { try { Log::info(Input::file('input_excel')); Excel::load($request->file('input_excel'), function ($reader) { $array = $reader->toArray(); Log::info($array); $banqueId = $this->gestSession->addBanqueByExcel($array[0]); Log::info("IdBanque1 " . $banqueId); $i = 1; while ($i < sizeof($array)) { Log::info($array); $titreIdGItem = $this->gestSession->addTitreGItemByExcel($array[$i]); Log::info("IdTitreGItem " . $titreIdGItem); $i++; while ($i < sizeof($array) && $array[$i]["label_item"] != null) { $this->gestSession->addItemByExcel($array[$i], $banqueId, $titreIdGItem); $i++; } } }); return Redirect::back(); } catch (\Exception $e) { echo "Format Incorrect"; } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'name' => 'max:100']); if ($validator->fails()) { return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput(); } if (Input::file('file')->isValid()) { $filePath = date('Ymd_His') . '.pdf'; if (Input::file('file')->move(base_path() . '/public/uploads/Announces/Announce-' . $request->get('year'), $filePath)) { //example of delete exist file $announceList = Announce::all(); if (sizeof($announceList) != 0) { $lastAnnounce = $announceList[sizeof($announceList) - 1]; $filename = base_path() . '/public/uploads/Announces/Announce-/' . $request->get('year') . '/' . $lastAnnounce->file_path; if (File::exists($filename)) { File::delete($filename); } // $oldAnnounce = Announce::findOrNew($lastAnnounce->id); $lastAnnounce = DB::table('announces')->where('year', $request->get('year'))->first(); // dd($lastAnnounce);die; if ($lastAnnounce != null) { Announce::destroy($lastAnnounce->id); } } $announce = new Announce(); $announce->file_path = $filePath; $announce->year = $request->get('year'); $announce->save(); return redirect('/announces'); } else { return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']); } } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'year' => 'required']); if ($validator->fails()) { return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput(); } //example of delete exist file $existMeetingReport = MeetingReport::where('year', '=', $request->get('year'))->where('no', '=', $request->get('no'))->first(); if ($existMeetingReport != null) { $filename = base_path() . '/public/uploads/Meeting-reports/' . $request->get('year') . '/' . $existMeetingReport->file_path; if (File::exists($filename)) { File::delete($filename); } MeetingReport::destroy($existMeetingReport->id); } if (Input::file('file')->isValid()) { $filePath = $request->get('no') . '.pdf'; if (Input::file('file')->move(base_path() . '/public/uploads/Meeting-reports/' . $request->get('year'), $filePath)) { $meetingReport = new MeetingReport(); $meetingReport->file_path = $filePath; $meetingReport->year = $request->get('year'); $meetingReport->no = $request->get('no'); $meetingReport->save(); return redirect('/admin/management'); } else { return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']); } } }
public function setUserPic($token) { $userId = DB::table('tokens')->where('token', '=', $token)->select('tokens.userId')->first(); $userId = $userId->userId; $file = array('image' => Input::file('image')); $rules = array('image' => 'required|image|max:200'); $validator = Validator::make($file, $rules); if ($validator->fails()) { $error = $validator->errors()->all(); return response()->json(['errorMessage' => $error], 404); } else { if (Input::file('image')->isValid()) { $destinationPath = public_path() . '/img/profile'; $extension = Input::file('image')->getClientOriginalExtension(); $fileName = 'image' . $userId . '.' . $extension; Input::file('image')->move($destinationPath, $fileName); $user = User::find($userId); if ($user->picture != null) { $picture = DB::table('users')->where('id', '=', $userId)->select('users.picture')->first(); $picture = $picture->picture; File::delete('img/profile/' . $picture); DB::table('users')->where('id', '=', $userId)->update(array('picture' => '')); } $user->picture = $fileName; $user->save(); return response()->json(['message' => 'file uploaded']); } else { return response()->json(['errorMessage' => 'upload failed'], 404); } } }
public function postCreate() { $rules = array('name' => 'required', 'cover_image' => 'required|image'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route('create_album_form')->withErrors($validator)->withInput(); } // end if $file = Input::file('cover_image'); $random_name = str_random(8); $destinationPath = 'albums/'; $extension = $file->getClientOriginalExtension(); $filename = $random_name . "." . $extension; $uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename); $album = Album::create(array('name' => Input::get('name'), 'description' => Input::get('description'), 'cover_image' => $filename, 'user_id' => \Sentry::getUser()->id)); /* $filename = Input::file('cover_image'); $random_name = str_random(8); $destinationPath = 'albums/'; $extension = $filename->getClientOriginalExtension(); $uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename . "." . $extension); $album = Album::create(array( 'name' => Input::get('name'), 'description' => Input::get('description'), 'cover_image' => $filename . "." . $extension, )); */ return Redirect::route('show_album', array('id' => $album->id)); }
public function postCreate() { $validator = Validator::make(Input::all(), ProductImage::$rules); if ($validator->passes()) { $images = Input::file('images'); $file_count = count($images); $uploadcount = 0; foreach ($images as $image) { if ($image) { $product_image = new ProductImage(); $product_image->product_id = Input::get('product_id'); $product_image->title = $image->getClientOriginalName(); $filename = date('Y-m-d-H:i:s') . "-" . $product_image->title; $path = public_path('img/products/' . $filename); $path_thumb = public_path('img/products/thumb/' . $filename); Image::make($image->getRealPath())->resize(640, 480)->save($path); Image::make($image->getRealPath())->resize(177, 177)->save($path_thumb); $product_image->url = $filename; $product_image->save(); $uploadcount++; } } if ($uploadcount == $file_count) { return Redirect::back(); } else { return Redirect::back()->with('message', 'Ошибка загрузки фотографии'); } } return Redirect::to('admin/products/index')->with('message', 'Ошибка сохранения')->withErrors($validator)->withInput(); }
public function saveData($request, $member_id = '') { // Upload $file_upload = Input::file('avatar'); $avatar = ''; if ($file_upload) { $filename = $file_upload->getClientOriginalName(); $extension = $file_upload->getClientOriginalExtension(); $avatar = sha1($filename . time()) . '.' . $extension; $destinationPath = config('custom.path_upload_member'); $file_upload->move($destinationPath, $avatar); } if ($member_id) { $member = self::find($member_id); } else { $member = new self(); } $member->avatar = $avatar ? $avatar : $member->avatar; $member->fullname = $request->input('fullname', ''); $member->team = $request->input('team_id', ''); $results = $member->save(); if ($results) { return $member->id; } else { return $results; } }
/** * Store a newly uploaded resource in storage. * * @return Response */ public function store(ImageRequest $request) { $input = $request->all(); if (Auth::user()->image != null) { $image = Auth::user()->image; $file = Input::file('image'); $name = time() . '-' . $file->getClientOriginalName(); $image->filePath = $name; $file->move(public_path() . '/images/', $name); } else { // Store records process $image = new Image(); $this->validate($request, ['title' => 'required', 'image' => 'required']); $image->title = $request->title; $image->description = $request->description; $image->user_id = Auth::user()->id; if ($request->hasFile('image')) { $file = Input::file('image'); $name = time() . '-' . $file->getClientOriginalName(); $image->filePath = $name; $file->move(public_path() . '/images/', $name); } } $image->save(); $user = Auth::user(); return redirect('/' . $user->username); }
public function import($entity) { $appHelper = new libs\AppHelper(); $className = $appHelper->getNameSpace() . $entity; $model = new $className(); $table = $model->getTable(); $columns = \Schema::getColumnListing($table); $key = $model->getKeyName(); $notNullColumnNames = array(); $notNullColumnsList = \DB::select(\DB::raw("SHOW COLUMNS FROM `" . $table . "` where `Null` = 'no'")); if (!empty($notNullColumnsList)) { foreach ($notNullColumnsList as $notNullColumn) { $notNullColumnNames[] = $notNullColumn->Field; } } $status = Input::get('status'); $filePath = null; if (Input::hasFile('import_file') && Input::file('import_file')->isValid()) { $filePath = Input::file('import_file')->getRealPath(); } if ($filePath) { \Excel::load($filePath, function ($reader) use($model, $columns, $key, $status, $notNullColumnNames) { $this->importDataToDB($reader, $model, $columns, $key, $status, $notNullColumnNames); }); } $importMessage = $this->failed == true ? \Lang::get('panel::fields.importDataFailure') : \Lang::get('panel::fields.importDataSuccess'); return \Redirect::to('panel/' . $entity . '/all')->with('import_message', $importMessage); }
public function import() { try { $file = Input::file('pricelist'); //$path = Input::file('pricelist')->getRealPath(); $temp = null; Excel::load($file, function ($reader) use($temp) { //$reader->dump(); $reader->skip(1); // Loop through all rows $reader->each(function ($row) { $carBrand = CarBrand::where('name', 'NISSAN')->first(); $carModel = CarModel::firstOrCreate(['name' => trim($row->d) . ' ' . trim($row->e), 'cartypeid' => $row->c, 'carbrandid' => $carBrand->id]); $carSubModel = CarSubModel::firstOrCreate(['code' => trim($row->g), 'name' => trim($row->f), 'carmodelid' => $carModel->id]); $pricelist = Pricelist::firstOrNew(['carmodelid' => $carModel->id, 'carsubmodelid' => $carSubModel->id, 'effectivefrom' => date('Y-m-d', strtotime(trim($row->a))), 'effectiveto' => date('Y-m-d', strtotime(trim($row->b))), 'sellingprice' => $row->i, 'accessoriesprice' => $row->j, 'sellingpricewithaccessories' => $row->h, 'margin' => $row->k, 'ws50' => $row->l, 'dms' => $row->m, 'wholesale' => $row->n, 'execusiveinternal' => $row->o, 'execusivecampaing' => $row->p, 'execusivetotalmargincampaing' => $row->q, 'internal' => $row->r, 'campaing' => $row->s, 'totalmargincampaing' => $row->t]); $pricelist->effectivefrom = trim($row->a); $pricelist->effectiveto = trim($row->b); $pricelist->save(); }); }); } catch (Exception $e) { return 'Message: ' . $e->getMessage(); } return redirect()->action('Settings\\PricelistController@index'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // register // Log::info('register pochetok'); // Log::info($request); // Log::info($request->get('first_name')); // ti dava samo value // Log::info($request->only('first_name')); // ti dava cela niza so key value $user = new User(); $user->first_name = $request->get('first_name'); $user->last_name = $request->get('last_name'); $user->email = $request->get('email'); $user->password = bcrypt($request->get('password')); $user->skype_id = $request->get('skype_id'); $user->contact_number = $request->get('contact_number'); if (Input::hasFile('profile_picture')) { Log::info('has file'); $file = Input::file('profile_picture'); $extension = pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION); $filename = base64_encode($user->email) . "." . $extension; $file->move('uploads/profile_pictures', $filename); // vistinskata profilna slika $image = Image::make('uploads/profile_pictures/' . $filename); $image->fit(160, 160); $image->save('uploads/profile_pictures/thumbnails/' . $filename); // update vo folder $user->profile_picture = $filename; } // proverka za email dali vekje ima (verojatno Eloquent sam kje vrati) imame staveno unique :) $user->save(); }
public function postUpdate() { $id = Input::get('id'); $slide = Slider::find($id); if ($slide) { $image = Input::file('image'); $slide->link = Input::get('link'); $slide->weight = Input::get('weight'); if ($image) { $slide->title = $image->getClientOriginalName(); $slide->title = $image->getClientOriginalName(); $filename = date('Y-m-d-H:i:s') . "-" . $slide->title; $path = public_path('img/slider/' . $filename); $path_thumb = public_path('img/slider/thumb/' . $filename); list($width, $height) = getimagesize($image); $coef_proportion = $width / $height; $height_original = 320; $height_thumb = 120; $width_original = $coef_proportion * $height_original; $width_thumb = $coef_proportion * $height_thumb; Image::make($image->getRealPath())->resize($width_original, $height_original)->save($path); Image::make($image->getRealPath())->resize($width_thumb, $height_thumb)->save($path_thumb); $slide->image = $filename; } $slide->save(); return Redirect::back()->with('message', "Элемент изменён"); } return Redirect::back()->with('message', 'Ошибка сохранения')->withInput(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'name' => 'max:100']); if ($validator->fails()) { return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput(); } $riskManagements = RiskManagement::where('year', '=', $request->get('year'))->where('period', '=', $request->get('period'))->get(); if (sizeof($riskManagements) > 0) { foreach ($riskManagements as $riskManagement) { $filename = base_path() . '/public/uploads/Risk-Management/' . $request->get('year') . '/' . $request->get('period') . '/' . $riskManagement->file_path; if (File::exists($filename)) { File::delete($filename); } RiskManagement::destroy($riskManagement->id); } } if (Input::file('file')->isValid()) { $filePath = date('Ymd_His') . '.pdf'; if (Input::file('file')->move(base_path() . '/public/uploads/Risk-Management/' . $request->get('year') . '/' . $request->get('period'), $filePath)) { //example of delete exist file $riskManagement = new RiskManagement(); $riskManagement->file_path = $filePath; $riskManagement->year = $request->get('year'); $riskManagement->period = $request->get('period'); $riskManagement->save(); return redirect('/admin/management'); } else { return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']); } } }
public function store() { // getting all of the post data $file = array('image' => Input::file('image')); $input = Request::all(); $image = $input['image']; // setting up rules $rules = array('image' => 'required'); //mimes:jpeg,bmp,png and for max size max:10000 // doing the validation, passing post data, rules and the messages $validator = Validator::make($image, $rules); if ($validator->fails()) { // send back to the page with the input data and errors return Redirect::to('/')->withInput()->withErrors($validator); } else { // checking file is valid. if (Input::file('image')->isValid()) { $destinationPath = '/uploads/images'; // upload path $extension = Input::file('image')->getClientOriginalExtension(); // getting image extension $fileName = rand(11111, 99999) . '.' . $extension; // renameing image Input::file('image')->move($destinationPath, $fileName); // uploading file to given path // sending back with message Session::flash('success', 'Upload successfully'); return Redirect::to('upload'); } else { // sending back with error message. Session::flash('error', 'uploaded file is not valid'); return Redirect::to('upload'); } } }
public function fileUpload() { // getting all of the post data $file = ['file' => Input::file('file')]; // setting up rules $rules = ['file' => 'required']; //mimes:jpeg,bmp,png and for max size max:10000 // doing the validation, passing post data, rules and the messages $validator = Validator::make($file, $rules); if ($validator->fails()) { // send back to the page with the input data and errors return false; } else { // checking file is valid. if (Input::file('file')->isValid()) { $destinationPath = $_SERVER['DOCUMENT_ROOT'] . '/public/uploads/files/'; // upload path $extension = Input::file('file')->getClientOriginalExtension(); // getting image extension $fileName = md5(date('YmdHis')) . '.' . $extension; // renaming image Uploads::create(['name' => Input::file('file')->getClientOriginalName(), 'original_name' => $fileName, 'mime_type' => Input::file('file')->getMimeType(), 'size' => Input::file('file')->getClientSize()]); Input::file('file')->move($destinationPath, $fileName); // uploading file to given path // sending back with message return ['filelink' => '/uploads/files/' . $fileName]; } else { // sending back with error message. return false; } } }
public function autoUpdate($save = false) { $this->getValue(); if ($this->action == "update" || $this->action == "insert") { if (Input::hasFile($this->name)) { $this->file = Input::file($this->name); $filename = $this->filename != '' ? $this->filename : $this->file->getClientOriginalName(); $uploaded = $this->file->move($this->path, $filename); if ($uploaded && is_object($this->model) && isset($this->db_name)) { if (!Schema::hasColumn($this->model->getTable(), $this->db_name)) { return true; } $this->new_value = $filename; if (isset($this->new_value)) { $this->model->setAttribute($this->db_name, $this->new_value); } else { $this->model->setAttribute($this->db_name, $this->value); } if ($save) { return $this->model->save(); } } } } return true; }
public function uploadFiles(Request $request) { $input = Input::all(); // $rules = array( // 'file' => 'image|max:3000', // ); // // $validation = Validator::make($input, $rules); // // if ($validation->fails()) { // return Response::make($validation->errors->first(), 400); // } $destinationPath = 'uploads'; // upload path $extension = Input::file('file')->getClientOriginalExtension(); // getting file extension $fileName = rand(11111, 99999) . '.' . $extension; // renameing image $upload_success = Input::file('file')->move($destinationPath, $fileName); // uploading file to given path // if ($request->file('file')->isValid()) { // return Response::json('success', 200); // } else { // return Response::json('error', 400); // } // return Response::json('success'); }
private function uploadValidator() { // when uploading a file with the POST named "upload" $expected_file_type = $this->file_type; $is_valid = false; $file = Input::file('upload'); if (empty($file)) { throw new \Exception(Lang::get('laravel-filemanager::lfm.error-file-empty')); } if (!$file instanceof UploadedFile) { throw new \Exception(Lang::get('laravel-filemanager::lfm.error-instance')); } $mimetype = $file->getMimeType(); if ($expected_file_type === 'Files') { $config_name = 'lfm.valid_file_mimetypes'; $valid_mimetypes = Config::get($config_name, $this->default_file_types); } else { $config_name = 'lfm.valid_image_mimetypes'; $valid_mimetypes = Config::get($config_name, $this->default_image_types); } if (!is_array($valid_mimetypes)) { throw new \Exception('Config : ' . $config_name . ' is not set correctly'); } if (in_array($mimetype, $valid_mimetypes)) { $is_valid = true; } if (false === $is_valid) { throw new \Exception(Lang::get('laravel-filemanager::lfm.error-mime') . $mimetype); } return $is_valid; }
public function postIndex() { $imagem = Input::file('imagem'); if (is_null($imagem)) { throw new Exception('Você não selecionou um arquivo'); } $destinationPath = public_path() . DIRECTORY_SEPARATOR . 'uploads'; $filename = date('YmdHis') . '_' . $imagem->getClientOriginalName(); if ($imagem->move($destinationPath, $filename)) { //Load view laravel paths $paths = Config::get('view.paths'); //Load file view $file = $paths[0] . DIRECTORY_SEPARATOR . Input::get('view') . '.blade.php'; $html = file_get_contents($file); //Init crawler $crawler = new HtmlPageCrawler($html); //Set filter $filter = '#' . Input::get('id'); //Edit node $crawler->filter($filter)->setAttribute('src', '/uploads/' . $filename); $newHTML = html_entity_decode($crawler->saveHTML()); $newHTML = str_replace('%7B%7B', '{{', $newHTML); $newHTML = str_replace('%7D%7D', '}}', $newHTML); $newHTML = str_replace('%24', '$', $newHTML); $newHTML = str_replace('%20', ' ', $newHTML); $newHTML = str_replace('%7C', '|', $newHTML); //write file file_put_contents($file, $newHTML); return Redirect::back()->with('alert', 'Banner enviado com sucesso!'); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store($image, $type, $primary_id, $current_link) { $image_link = array_key_exists($type, Input::all()) ? Input::file($type) != '' ? '/allgifted-images/' . $type . '/' . $primary_id . '.' . $image->getClientOriginalExtension() : $current_link : $current_link; array_key_exists($type, Input::all()) ? File::exists(public_path($image_link)) ? File::delete(public_path($image_link)) : null : null; $image ? Image::make($image)->fit(500, 300)->save(public_path($image_link)) : null; return $image_link; }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { //$this->validate($request, ['name' => 'required']); // Uncomment and modify if needed. $valoriformular = array('HotelID' => $request->HotelID, 'DetaliiScurte' => $request->DetaliiScurte, 'DetaliiComplete' => $request->DetaliiComplete, 'ServiciiIncluse' => $request->ServiciiIncluse, 'ExtraServicii' => $request->ExtraServicii, 'DataExpirare' => $request->DataExpirare); $insertformular = Ofertestatices::create($valoriformular); $id = $insertformular->id; $files = Input::file('DocOferta'); $file_count = count($files); $uploadcount = 0; foreach ($files as $file) { $rules = array('file' => 'required'); $validare = Validator::make(array('file' => $file), $rules); if ($validare->passes()) { $destinationPath = 'oferte'; // upload path $extension = $file->getClientOriginalExtension(); // getting image extension $fileName = rand(11111, 99999) . '.' . $extension; // renameing image $upload = $file->move($destinationPath, $fileName); $valoridoc = array('idOferta' => $id, 'url' => 'oferte/' . $fileName); Documente::create($valoridoc); $uploadcount++; } } if ($uploadcount == $file_count) { return redirect("admin/oferte"); } }
/** * Save message to Discussion page * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function saveDiscussion() { $input = Input::all(); $message = new Message(); $message->body = $input['message']; $message->user_id = Auth::user()->id; // Storing image file, if it is attached if (Input::hasFile('image')) { $file = Input::file('image'); if ($file->isValid()) { $filename = rand(111111, 999999) . '-' . $file->getClientOriginalName(); $destination_path = 'uploads/projects/'; $file->move($destination_path, $filename); $message->attachment = $filename; // Make a thumbnail picture $thumbnail = Image::make($destination_path . '/' . $filename); $thumbnail->resize(55, null, function ($constraint) { $constraint->aspectRatio(); }); $thumbnail->save('uploads/projects/thumbnails/' . $filename); } } $message->save(); return redirect('/projects/discussion'); }
public function upload() { $userName = Auth::user()->id; if (Input::hasFile('rnaVcfFile')) { $fileRNA = Input::file('rnaVcfFile'); if ($fileRNA->isValid()) { /*$clientName = $file->getClientOriginalName(); $tmpName = $file->getFileName(); $realPath = $file->getRealPath(); $entension = $file->getClientOriginalExtension(); $mimeType = $file->getMimeType();*/ $newName = $userName . '_rna.vcf'; /*$path = */ $fileRNA->move('../storage/vcf_file', $newName); redirect('/'); } } elseif (Input::hasFile('dnaVcfFile')) { $fileDNA = Input::file('dnaVcfFile'); if ($fileDNA->isValid()) { $newName = $userName . '_dna.vcf'; /*$path = */ $fileDNA->move('../storage/vcf_file', $newName); redirect('/'); } } }
public function registerUser() { $name = Input::get('register_name'); $email = Input::get('register_email'); $username = Input::get('register_usr'); $pass = Input::get('register_pass'); $fileName = 'no_img.jpg'; if (Input::file('register_photo')) { $file = array('image' => Input::file('register_photo')); // setting up rules $rules = array('image' => 'required'); //mimes:jpeg,bmp,png and for max size max:10000 // doing the validation, passing post data, rules and the messages $validator = Validator::make($file, $rules); if ($validator->fails()) { // send back to the page with the input data and errors // return Redirect::to('login')->withInput()->withErrors($validator); // print_r("error"); } if (Input::file('register_photo')->isValid()) { $destinationPath = 'uploads'; // upload path $extension = Input::file('register_photo')->getClientOriginalExtension(); // getting image extension $fileName = rand(11111, 99999) . '.' . $extension; // renameing image Input::file('register_photo')->move($destinationPath, $fileName); // uploading file to given path // sending back with message } } Login::insertUser($name, $username, $pass, $fileName, $email); $this->sendEmail($email, $name); Redirect::to('login')->with('test', 'test')->send(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $a = new \App\Popups(); $a->judul = Input::get('judul'); $a->slug = str_slug(Input::get('judul')); $a->deskripsi = Input::get('keterangan'); $a->tipe_valid = Input::get('type_valid'); if ($a->tipe_valid == "by_datetime" or $a->tipe_valid == "by_date") { $a->date_valid_start = date_format(date_create(Input::get('date_valid_start')), "Y-m-d"); $a->date_valid_end = date_format(date_create(Input::get('date_valid_end')), "Y-m-d"); } if ($a->tipe_valid == "by_datetime" or $a->tipe_valid == "by_time") { $a->time_valid_start = date_format(date_create(Input::get('time_valid_start')), "H:i:s"); $a->time_valid_end = date_format(date_create(Input::get('time_valid_end')), "H:i:s"); } if (Input::hasFile('image') and Input::file('image')->isValid()) { $image = date("YmdHis") . uniqid() . "." . Input::file('image')->getClientOriginalExtension(); Input::file('image')->move(storage_path() . '/popup_image', $image); $a->image = $image; } $a->keep_open = Input::get('keep_open'); $a->hotlink = Input::get('hotlink'); $a->idpengguna = Auth::user()->id; $a->save(); return redirect(url('admin/popups')); }
public function duzenleForm($id) { $data = Input::all(); $kural = array('baslik' => 'required|min:3', 'resim' => 'max:1536|required|mimes:jpeg,jpg,bmp,png,gif'); $dogrulama = \Validator::Make($data, $kural); if (!$dogrulama->passes()) { return \Redirect::to('admin/galeriler/duzenle/' . $id)->withErrors($dogrulama)->withInput(); } else { if (Input::hasFile('resim')) { $dosya = Input::file('resim'); $uzanti = $dosya->getClientOriginalExtension(); if (strlen($uzanti) == 3) { $dosyaAdi = substr($dosya->getClientOriginalName(), 0, -4); } else { if (strlen($uzanti) == 4) { $dosyaAdi = substr($dosya->getClientOriginalName(), 0, -5); } } $dosyaAdi = $dosyaAdi . "_" . date('YmdHis') . '.' . $uzanti; $path = base_path('galeriResimler/600x450/' . $dosyaAdi); Image::make($dosya->getRealPath())->resize(600, 450)->save($path); $path = base_path('galeriResimler/defaultSize/' . $dosyaAdi); Image::make($dosya->getRealPath())->save($path); $path = $dosyaAdi; $query = DB::insert('insert into gal_resim values (null,?,?,?)', array($id, $data["baslik"], $path)); return Redirect::back(); } } }
public function postimage(Request $request) { $user = User::whereId(Auth::user()->id)->first(); $path = public_path() . '/images/profiles/'; $currentimage = $path . $user->avatar; if ($user->avatar != 'default.png') { \File::delete($currentimage); } if (Input::hasFile('file')) { $this->validate($request, ['file' => ['required', 'image']]); $file = Input::file('file'); $filename = Auth::user()->id . '_' . time() . '.' . Input::file('file')->guessClientExtension(); $img = Image::make($file); $img->fit(300, 300, function ($constraint) { $constraint->aspectRatio(); })->save($path . $filename); $user->avatar = $filename; $user->save(); return 'ok -' . $filename; } else { $user->avatar = 'default.png'; $user->save(); return redirect('/membres/profil/'); } }