本文整理汇总了PHP中Illuminate\Support\Facades\Input::hasFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::hasFile方法的具体用法?PHP Input::hasFile怎么用?PHP Input::hasFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Input
的用法示例。
在下文中一共展示了Input::hasFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: duzenleForm
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();
}
}
}
示例2: upload
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('/');
}
}
}
示例3: validateFiles
/**
* 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;
}
示例4: autoUpdate
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;
}
示例5: store
/**
* 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'));
}
示例6: EditProduct
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);
}
示例7: store
/**
* 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'));
}
示例8: parseSettings
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;
}
示例9: store
/**
* 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();
}
示例10: postUpload
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);
}
}
示例11: save_koperasi
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'));
}
示例12: import
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);
}
示例13: postImport
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();
}
示例14: upload
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');
}
}
示例15: store
/**
* 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();
}