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 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('/'); } } }
/** * Validates files inside the files form field individually. * * @return bool */ public function validateFiles() { // Make sure files have been uploaded if (Input::hasFile('files')) { // Get the uploaded files $files = Input::file('files'); // Make sure the files is an array and more than one exists if (is_array($files) && count($files) > 0) { foreach ($files as $file) { // Dynamically set the input to the current file $this->setInput(['files' => $file]); $validator = $this->validator(); // Check the file against the validator if ($validator->passes()) { continue; } else { // Set the messages for the file and return false $this->setErrors($validator->messages()); return false; } } return true; } } else { $messages = ['files' => trans('validation.required', ['attribute' => 'files'])]; $errors = new MessageBag($messages); $this->setErrors($errors); } 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; }
/** * 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 EditProduct($id) { $title = $_POST["productTitle"]; $description = $_POST["productDescription"]; $price = $_POST["productPrice"]; $hasModels = $_POST["productHasModels"]; $category = $_POST["productCategory"]; $subcategory = $_POST["subCategorySelect"]; if (Input::hasFile("product_picture")) { $has_file = true; $file = Input::file("product_picture"); $folder = '/images/'; $destinationPath = public_path() . $folder; $filename = str_random(6) . '_' . $file->getClientOriginalName(); $img_path = $folder . $filename; $uploadSuccess = $file->move($destinationPath, $filename); $pd = Product::GetProductByID($id); $img = $pd[0]->product_image; if (File::exists(public_path() . $img)) { File::delete(public_path() . $img); } } else { $has_file = false; $pd = Product::GetProductByID($id); $img = $pd[0]->product_image; $img_path = $img; } Product::EditProduct($id, $title, $description, $price, $category, $subcategory, $img_path, $hasModels); return Redirect::to("admin/edit_product/" . $id); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // if ($this->checkauth(9)['err'] == 1) { return $this->checkauth(9)['view']; } $divisi = new Activities(); $divisi->judul = Input::get('judul'); $divisi->jenis = 'text'; $divisi->isi = Input::get('isi'); if (Input::hasFile('gambar') and Input::file('gambar')->isValid()) { $gambar = date("YmdHis") . uniqid() . "." . Input::file('gambar')->getClientOriginalExtension(); Input::file('gambar')->move(storage_path() . '/activities', $gambar); $divisi->isi = $gambar; $divisi->jenis = 'picture'; } if (Input::get('video') != "") { $divisi->isi = Input::get('video'); $divisi->jenis = 'video'; } if (Input::get('url') != "") { $divisi->isi = Input::get('url'); $divisi->jenis = 'urlimage'; } $divisi->save(); return redirect(url('admin/activities')); }
private function parseSettings() { $settings = SettingItem::hasInterface()->get(); $parsedSettings = array(); foreach ($settings as $setting) { if ($setting->isFile() || $setting->isImage()) { if (Input::has("setting.{$setting->setting_key}")) { $value = Input::get("setting.{$setting->setting_key}"); if (Input::hasFile($setting->setting_key)) { $subFolder = ($setting->isImage() ? "images" : "files") . "/"; $newFilename = uniqid() . "_" . time() . "." . Input::file($setting->setting_key)->getClientOriginalExtension(); $file = Input::file($setting->setting_key); $file->move(AssetsHelper::uploadPath($subFolder), $newFilename); $value = $subFolder . $newFilename; } $parsedSettings[$setting->setting_key] = $value; } } else { if ($setting->isMultipleChoice()) { $parsedSettings[$setting->setting_key] = implode("|||", Input::get("setting.{$setting->setting_key}")); } else { if (Input::has("setting.{$setting->setting_key}")) { $parsedSettings[$setting->setting_key] = Input::get("setting.{$setting->setting_key}"); } else { if (!$setting->isRequired()) { $parsedSettings[$setting->setting_key] = Input::get("setting.{$setting->setting_key}"); } } } } } return $parsedSettings; }
/** * 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 postUpload() { if (Input::hasFile('file')) { $file = Input::file('file'); // query uploaded file // $filename = $file->getClientOriginalName(); $path = $file->getRealPath(); $extension = $file->getClientOriginalExtension(); $mime = $file->getMimeType(); $size = $file->getSize(); // replace spaces in filename with dashes // $filename = Filename::sanitize($filename); // move file to destination // // $destinationFolder = str_random(8); $destinationFolder = GUID::create(); $destinationPath = '/swamp/incoming/' . $destinationFolder; $uploadSuccess = Input::file('file')->move($destinationPath, $filename); if ($uploadSuccess) { return Response::make(array('uploaded_file' => $filename, 'path' => $path, 'extension' => $extension, 'mime' => $mime, 'size' => $size, 'destination_path' => $destinationFolder), 200); } else { return Response::make('Error moving uploaded file.', 400); } } else { return Response::make('No uploaded file.', 404); } }
public function save_koperasi() { $v = Validator::make(Input::all(), ['nama' => 'required', 'alamat' => 'required']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } $new = \App\Koperasi::find(Auth::user()->assigned_koperasi); $new->nama = Input::get('nama'); $new->email = Input::get('email'); $new->no_telp = Input::get('no_telp'); $new->no_fax = Input::get('no_fax'); $new->alamat = Input::get('alamat'); $new->rtrw = Input::get('rtrw'); $new->kel = Input::get('kel'); $new->kec = Input::get('kec'); $new->kabkota = Input::get('kabkota'); $new->prov = Input::get('prov'); $new->kodepos = Input::get('kodepos'); $new->negara = Input::get('negara'); if (Input::hasFile('logo')) { $logo = date("YmdHis") . uniqid() . "." . Input::file('logo')->getClientOriginalExtension(); Input::file('logo')->move(storage_path("images"), $logo); $new->logo = $logo; } $new->save(); return redirect(url('pengaturan/koperasi')); }
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 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(); }
public function upload(Request $request) { $file = $request->file('image'); if (Input::hasFile('image')) { $destinationPath = '/storage/avatars/'; $size = $file->getSize(); if ($size <= 41943040) { $fileName = Auth::user()->id . '.' . 'jpg'; $file->move(base_path() . $destinationPath, $fileName); if (DB::table('photos')->where('user_id', Auth::user()->id)->value('user_id') == Auth::user()->id) { } else { $photos = new Photo(); //обращается к контроллеру??? $photos->user_id = Auth::user()->id; $photos->url = 'storage/avatars/' . $fileName; //ссылки на картинки $photos->main = 1; $photos->save(); } return view('home'); } else { return view('errors.bigFile'); } } else { return view('errors.noUploadFile'); } }
/** * 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(); }
/** * 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'); }
/** * @return mixed */ public function postEkle() { $validation = Validator::make(Input::all(), ['name' => 'required|unique:settings', 'title' => 'required|max:255', 'description' => 'required|max:255', 'keywords' => 'required|max:255', 'favicon' => 'mimes:jpeg,ico,png,jpg|max:500']); if ($validation->fails()) { return Redirect::back()->withInput()->withErrors($validation->messages()); } if (Input::hasFile('favicon')) { $file = Input::file('favicon'); $extension = $file->getClientOriginalExtension(); $filename = rand(11111, 99999) . '.' . $extension; $file->move('img', $filename); } else { $filename = "favicon.ico"; } if (Input::get('active') == 1) { Setting::where('active', '=', 1)->update(['active' => 0]); } $settings = new Setting(); $settings->name = Input::get('name'); $settings->title = Input::get('title'); $settings->description = Input::get('description'); $settings->keywords = Input::get('keywords'); $settings->active = Input::get('active'); $settings->favicon = $filename; if ($settings->save()) { return Redirect::back()->withInput()->with(array('basarili' => 'Ayar başarı ile kaydedildi.')); } else { return Redirect::back()->withInput()->with(array('errors' => 'Ayar kaydedilemedi.')); } }
public static function getPathFromInput($input_name) { if (Input::hasFile($input_name)) { return $path = Input::file($input_name)->getRealPath(); } else { throw new NotFoundException('File non found.'); } }
public function upload() { if (Input::hasFile('file')) { echo "Uploaded"; $file = Input::file('file'); $file->move('uploads', $file->getClientOriginalName()); echo '<img class="img-rounded" src= "Uploads/' . $file->getClientOriginalName() . '" style="width:200px;height:200px;"/>'; } }
/** * Update a ProductImage. * * @route PUT|PATCH /api/v1/products/:product_sku/images/:uid * @authentication required */ public function update($product_sku, $uid) { $product = Subbly::api('subbly.product')->find($product_sku); if (!Input::hasFile('product_image')) { return $this->jsonErrorResponse('"product_image" is required.'); } $productImage = Subbly::api('subbly.product_image')->update($uid, array('image' => Input::file('product_image'))); return $this->jsonResponse(array('product_image' => $productImage), array('status' => array('code' => 200, 'message' => 'ProductImage updated'))); }
public function postStore() { $id = Input::get('id'); /* * Validate */ $rules = array('image' => 'mimes:jpg,jpeg,png,gif|max:500', 'name' => 'required', 'short_description' => 'required', 'long_description' => 'required', 'start_date' => 'required', 'end_date' => 'required'); $validation = Validator::make(Input::all(), $rules); if ($validation->passes()) { $name = Input::get('name'); $short_description = Input::get('short_description'); $long_description = Input::get('long_description'); $image = Input::file('image'); $active = Input::get('active') == '' ? FALSE : TRUE; $cn_name = Input::get('cn_name'); $cn_short_description = Input::get('cn_short_description'); $cn_long_description = Input::get('cn_long_description'); $options = array('name' => $cn_name, 'short_description' => $cn_short_description, 'long_description' => $cn_long_description); $start_date = DateTime::createFromFormat('d/m/Y', Input::get('start_date')); $end_date = DateTime::createFromFormat('d/m/Y', Input::get('end_date')); $promotion = isset($id) ? Promotion::find($id) : new Promotion(); $promotion->name = $name; $promotion->start_date = $start_date; $promotion->end_date = $end_date; $promotion->short_description = $short_description; $promotion->long_description = $long_description; $promotion->active = $active; $promotion->options = json_encode($options); $promotion->save(); if (Input::hasFile('image')) { // Delete all existing images for edit if (isset($id)) { $promotion->deleteAllImages(); } //set the name of the file $originalFilename = $image->getClientOriginalName(); $filename = 'promo' . date("dmY") . '_' . Str::random(20) . '.' . File::extension($originalFilename); //Upload the file $isSuccess = $image->move('assets/img/promotions', $filename); if ($isSuccess) { // create photo $newimage = new Image(); $newimage->path = $filename; // save photo to the loaded model $promotion->images()->save($newimage); } } } else { if (isset($id)) { return Redirect::to('admin/promotions/edit/' . $id)->withErrors($validation)->withInput(); } else { return Redirect::to('admin/promotions/create')->withErrors($validation)->withInput(); } } return Redirect::to('admin/promotions'); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { // UploadPhoto service. if (Input::hasFile('profile_picture')) { $file = Input::file('profile_picture'); $extension = pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION); $file->move('uploads/profile_pictures', base64_encode($file->getClientOriginalName()) . "." . $extension); } return User::create(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'skype_id' => $data['skype_id'], 'profile_picture' => base64_encode($file->getClientOriginalName()) . "." . $extension, 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
private function postUploadImage() { if (Input::hasFile('image')) { $destinationPath = public_path() . '/uploads'; $extension = Input::file('image')->getClientOriginalExtension(); // getting image extension $fileName = rand(11111, 99999) . '.' . $extension; // renameing image Input::file('image')->move($destinationPath, $fileName); return $fileName; } }
public function update(Request $request, $id) { $this->wish = Wish::find($id); $this->wish->fill($request->all()); if (Input::hasFile('picture')) { File::delete(public_path('img/wishes/') . $this->wish->picture); $this->wish->picture = $this->uploadImage(Input::file('picture')); } $this->wish->url = Parent::addScheme($request->url); $this->wish->save(); return redirect()->route('wishes.index'); }
/** * Upload an image/file and (for images) create thumbnail * * @param UploadRequest $request * @return string */ public function upload() { // sanity check if (!Input::hasFile('file_to_upload')) { // there ws no uploded file return "You must choose a file!"; exit; } if (Session::get('lfm_type') == "Images") { $file = Input::file('file_to_upload'); $working_dir = Input::get('working_dir'); $destinationPath = base_path() . "/" . $this->file_location; $extension = $file->getClientOriginalExtension(); if (!empty($this->allowed_types["Images"]) && !in_array($extension, $this->allowed_types["Images"])) { return "File type is not allowed!"; exit; } if (strlen($working_dir) > 1) { $destinationPath .= $working_dir . "/"; } $filename = $file->getClientOriginalName(); $new_filename = Str::slug(str_replace($extension, '', $filename)) . "." . $extension; Input::file('file_to_upload')->move($destinationPath, $new_filename); if (!File::exists($destinationPath . "thumbs")) { File::makeDirectory($destinationPath . "thumbs"); } $thumb_img = Image::make($destinationPath . $new_filename); $thumb_img->fit(200, 200)->save($destinationPath . "thumbs/" . $new_filename); unset($thumb_img); return "OK"; } else { $file = Input::file('file_to_upload'); $working_dir = Input::get('working_dir'); $destinationPath = base_path() . "/" . $this->file_location; $extension = $file->getClientOriginalExtension(); if (!empty($this->allowed_types["Files"]) && !in_array($extension, $this->allowed_types["Files"])) { return "File type is not allowed!"; exit; } if (strlen($working_dir) > 1) { $destinationPath .= $working_dir . "/"; } $filename = $file->getClientOriginalName(); $new_filename = Str::slug(str_replace($extension, '', $filename)) . "." . $extension; if (File::exists($destinationPath . $new_filename)) { return "A file with this name already exists!"; exit; } Input::file('file_to_upload')->move($destinationPath, $new_filename); return "OK"; } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(ArticleRequest $request) { $article = new Article($request->all()); if (Input::hasFile('image')) { $file = Input::file('image'); $name = time() . '-' . $file->getClientOriginalName(); $file->move(public_path() . '/images/', $name); $article->thumbnail = $name; } $article->save(); \Session::flash('flash_message', 'Article Created'); return redirect('/blog/'); }
public static function request() { $class = new static(); $class->action = Input::get('action'); foreach (array_keys(Input::all()) as $k) { if (Input::hasFile($k)) { // @todo attention $class->uploadedIds = array_merge($class->uploadedIds, $class->upload('image', $k, null, null, '', null, true)); event('veer.message.center', trans('veeradmin.image.upload')); } } !Input::has('attachImages') ?: $class->attachImages(Input::get('attachImages')); !starts_with($class->action, 'deleteImage') ?: $class->delete(substr($class->action, 12)); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(CreateBedRoomRequest $request) { $file = Input::file('image'); if (Input::hasFile('image')) { $fileName = $file->getClientOriginalName(); $path = public_path() . '\\uploads\\'; $bedroom = new Bedroom($request->all()); $bedroom->image = $fileName; if ($file->move($path, $fileName)) { $bedroom->save(); return redirect()->route('admin.properties.index'); } } }
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) { $decommission = new \App\Models\Decommission(); $name = iconv("Windows-1251", "utf-8", $data[0]); $decommission->name = $name; $decommission->number = $data[1]; $carrying_amount = $data[2]; $carrying_amount = str_replace(",", ".", $carrying_amount); $carrying_amount = str_replace(" ", "", $carrying_amount); $decommission->carrying_amount = $carrying_amount; $date = date("Y-m-d", strtotime($data[3])); $decommission->date = $date; $decommission_type = $data[4]; $decommission_type = str_replace(" ", "", $decommission_type); switch ($decommission_type) { case 1: $decommission->type = 'sale'; break; case 2: $decommission->type = 'gratuitous transfer'; break; case 3: $decommission->type = 'decommission'; break; default: $decommission->type = null; } $sum = $data[5]; $sum = str_replace(",", ".", $sum); $sum = str_replace(" ", "", $sum); $decommission->sum = $sum; $document = iconv("Windows-1251", "utf-8", $data[6]); $decommission->document = $document; $decommission->report_id = $id; $decommission->save(); } } } 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/'); } }