当前位置: 首页>>代码示例>>PHP>>正文


PHP Input::hasFile方法代码示例

本文整理汇总了PHP中Input::hasFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::hasFile方法的具体用法?PHP Input::hasFile怎么用?PHP Input::hasFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Input的用法示例。


在下文中一共展示了Input::hasFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:aoslee,项目名称:panel,代码行数:28,代码来源:ExportImportController.php

示例2: createParent

 public function createParent()
 {
     $input = Input::all();
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'));
     }
     $input['dob'] = date('Y-m-d H:i:s', strtotime(Input::get('dob')));
     $input['collegeid'] = Session::get('user')->collegeid;
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     $removed = array('_token', 'password', 'cpassword');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Parent::saveFormData($input);
     return $input;
 }
开发者ID:pankaja455,项目名称:WebSchool,代码行数:25,代码来源:ParentController.php

示例3: edit

 public function edit($id)
 {
     $exist = Book::where('id', $id)->count();
     if ($exist == 0) {
         Session::put('msgfail', 'Invalid input.');
         return Redirect::back()->withInput();
     }
     $rules = array('name' => 'required', 'author' => 'required', 'date' => 'required', 'file' => 'mimes:jpeg,bmp,png');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         Session::put('msgfail', 'Invalid input.');
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $book_save = Book::find($id);
         $destinationPath = '';
         $filename = $book_save->file;
         if (Input::hasFile('file')) {
             $file = Input::file('file');
             $destinationPath = public_path() . '/uploads/book/';
             $filename = str_random(6) . '_' . $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
         }
         $book_save->name = strip_tags(Input::get('name'));
         $book_save->author = strip_tags(Input::get('author'));
         $book_save->date = Input::get('date');
         $book_save->file = $filename;
         $book_save->save();
         Session::put('msgsuccess', 'Successfully edited book.');
         return Redirect::to("/books");
     }
 }
开发者ID:johnarben2468,项目名称:samplecrud,代码行数:31,代码来源:BookController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = ['title' => 'required', 'content' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/teacher/posts/create')->withErrors($validator);
     } else {
         $post = new Post();
         $post->title = Input::get('title');
         $post->content = Input::get('content');
         // variables liées à la gestion de l'image
         $destinationPath = '';
         $filename = '';
         if (Input::hasFile('image')) {
             $file = Input::file('image');
             $destinationPath = $destinationPath = public_path() . '/img/';
             $filename = $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
             $post->url_thumbnail = $filename;
         }
         $post->abstract = Str::words($post->content, 20, '...');
         $post->user_id = Auth::user()->id;
         $post->save();
         /*echo "<pre>";
         		var_dump(public_path().'\\img\\'.'lol.jpg');
         		echo '</pre>';*/
         Session::flash('message_success', 'L\'article a bien été ajouté');
         return Redirect::to('/teacher/posts');
     }
 }
开发者ID:resethread,项目名称:elycee,代码行数:35,代码来源:PostsController.php

示例5: update

 /**
  * Update the specified powerful in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $powerful = Powerful::findOrFail($id);
     $rules = array('name' => 'required', 'icon' => 'image');
     $validator = Validator::make($data = Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //upload powerful icon
     if (Input::hasFile('icon')) {
         //delete old icon
         if (File::exists($powerful->icon)) {
             File::delete($powerful->icon);
         }
         //create new icon
         $name = md5(time() . Input::file('icon')->getClientOriginalName()) . '.' . Input::file('icon')->getClientOriginalExtension();
         $folder = "public/uploads/powerful";
         Input::file('icon')->move($folder, $name);
         $path = $folder . '/' . $name;
         //update new path
         $data['icon'] = $path;
     } else {
         unset($data['icon']);
     }
     $powerful->update($data);
     return Redirect::route('admin.powerful.index')->with('message', 'Item had updated!');
 }
开发者ID:vnzacky,项目名称:exp_services,代码行数:33,代码来源:PowerfulController.php

示例6: uploadImage

 public static function uploadImage($user_id)
 {
     $error_code = ApiResponse::OK;
     if (User::where('user_id', $user_id)->first()) {
         $profile = Profile::where('user_id', $user_id)->first();
         if (Input::hasFile('file')) {
             $file = Input::file('file');
             $destinationPath = public_path() . '/images/' . $user_id . '/avatar';
             $filename = date('YmdHis') . '_' . $file->getClientOriginalName();
             $extension = $file->getClientOriginalExtension();
             if (!File::isDirectory($destinationPath)) {
                 File::makeDirectory($destinationPath, $mode = 0777, true, true);
             }
             $upload_success = $file->move($destinationPath, $filename);
             $profile->image = 'images/' . $user_id . '/avatar/' . $filename;
             $profile->save();
             $data = URL::asset($profile->image);
         } else {
             $error_code = ApiResponse::MISSING_PARAMS;
             $data = null;
         }
     } else {
         $error_code = ApiResponse::UNAVAILABLE_USER;
         $data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_USER);
     }
     return array("code" => $error_code, "data" => $data);
 }
开发者ID:anht37,项目名称:winelover_server,代码行数:27,代码来源:Profile.php

示例7: postUpload

 public function postUpload()
 {
     $agente = Agente::find(1);
     if (Input::hasFile('file')) {
         $file = Input::file('file');
         $name = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $size = File::size($file);
         //dd($extension);
         $data = array('nombre' => $name, 'extension' => $extension, 'size' => $size);
         $rules = array('extension' => 'required|mimes:jpeg');
         $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'unique' => 'La factura ingresada ya está agregada en la base de datos.', 'confirmed' => 'Los passwords no coinciden.', 'mimes' => 'El campo :attribute debe ser un archivo de tipo :values.');
         $validation = Validator::make($rules, $messages);
         if ($validation->fails()) {
             return Redirect::route('logo-post')->withInput()->withErrors($validation);
         } else {
             if ($extension != 'jpg') {
                 return Redirect::route('logo-post')->with('global', 'Es necesario que la imagen sea de extension .jpg.');
             } else {
                 $path = public_path() . '/assets/img/';
                 $newName = 'logo';
                 $subir = $file->move($path, $newName . '.' . $extension);
                 return Redirect::route('agente.index')->with('create', 'El logo ha sido actualizado correctamente!');
             }
         }
     } else {
         return Redirect::route('logo-post')->with('global', 'Es necesario que selecciones una imagen.');
     }
 }
开发者ID:joserph,项目名称:app-retenciones,代码行数:29,代码来源:LogoController.php

示例8: postPublish

 public function postPublish()
 {
     $msg = 'Report Successfully Published';
     $inputs = Input::except('notify');
     foreach (Input::all() as $key => $single_input) {
         if (empty($single_input) && (stristr($key, 'state') || stristr($key, 'city'))) {
             unset($inputs[$key]);
         }
     }
     $inputs['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $inputs['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
     if (!Input::hasFile('kid_image')) {
         unset($inputs['kid_image']);
     } else {
         $file = Input::file('kid_image');
         $destination_path = 'admin/images/upload/';
         $filename = str_random(15) . '.' . $file->getClientOriginalExtension();
         $file->move($destination_path, $filename);
         $inputs['kid_image'] = $destination_path . $filename;
     }
     if (Input::get('clicked') == 'Success') {
         // if the report is marked as a success
         $inputs['status'] = 9;
         $msg = 'Report Successfully Marked As Success';
     } else {
         //if the report is updated or published
         $inputs['status'] = 1;
     }
     unset($inputs['clicked']);
     Found::where('id', '=', Input::get('id'))->update($inputs);
     return Redirect::to('admin/found/published')->with('success', $msg);
 }
开发者ID:jencko,项目名称:bbk,代码行数:32,代码来源:FoundReportController.php

示例9: createStudent

 public function createStudent()
 {
     $validator = $this->validateStudent(Input::all());
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::to('student-new')->withErrors($messages)->withInput(Input::except('password', 'password_confirmation'));
     }
     $input = Input::all();
     //$input['dob'] = date('m-d-Y H:i:s', strtotime(Input::get('dob')));
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     $input['collegeid'] = Session::get('user')->collegeid;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'), $user->id);
     }
     $removed = array('password', 'password_confirmation');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Student::saveFormData($input);
     return Redirect::to('student');
 }
开发者ID:pankaja455,项目名称:WebSchool,代码行数:30,代码来源:StudentController.php

示例10: postUpload

 public function postUpload()
 {
     $data = Input::all();
     $rules = array('category' => 'required');
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         if (Input::hasFile('file')) {
             $contents = file_get_contents(Input::file('file')->getRealPath());
             $decoded = Bencode::decode($contents);
             $torrent = new Torrent();
             $torrent->name = $decoded['info']['name'];
             $torrent->size = 0;
             $torrent->downloads = 0;
             $torrent->file = $contents;
             $torrent->category_id = $data['category'];
             $torrent->uploader_id = Auth::user()->id;
             $torrent->save();
             $files = array();
             if (!empty($decoded['info']['files'])) {
                 foreach ($decoded['info']['files'] as $file) {
                     $files[] = array('torrent_id' => $torrent->id, 'name' => implode('/', $file['path']), 'size' => $file['length']);
                     $torrent->size += $file['length'];
                 }
             } else {
                 $files[] = array('torrent_id' => $torrent->id, 'name' => $decoded['info']['name'], 'size' => $decoded['info']['length']);
                 $torrent->size += $decoded['info']['length'];
             }
             //http://stackoverflow.com/questions/12702812/bulk-insertion-in-laravel-using-eloquent-orm
             TorrentFile::insert($files);
             $torrent->save();
             return Redirect::action('TorrentController@getDetails', array($torrent->id))->with('success', 'Your torrent has been added!');
         }
     }
     return Redirect::to('/upload')->withInput()->withErrors($validator);
 }
开发者ID:ne0lite,项目名称:Tracker,代码行数:35,代码来源:TorrentController.php

示例11: store

 public function store()
 {
     if ($_POST) {
         $input = Input::all();
         $rules = array('username' => 'required|unique:users', 'password' => 'required', 'email' => 'required|unique:users|email', 'firstname' => 'required|Alpha', 'lastname' => 'required|alpha_dash', 'city' => 'required', 'country' => 'required|Alpha', 'recaptcha_response_field' => 'required|recaptcha');
         $validator = Validator::make($input, $rules);
         if ($validator->fails()) {
             return Redirect::to('register')->withInput()->withErrors($validator);
         } else {
             $user = new User();
             $user->username = Input::get('username');
             $user->password = Hash::make(Input::get('password'));
             $user->firstname = Input::get('firstname');
             $user->lastname = Input::get('lastname');
             $user->email = Input::get('email');
             $user->city = Input::get('city');
             $user->country = Input::get('country');
             $user->organisation = Input::get('organisation');
             $user->description = Input::get('description');
             $user->picture = '';
             $user->suspended = 0;
             if (Input::hasFile('picture')) {
                 $file = Input::file('picture');
                 $pixpath = '/uploads/pix/user/';
                 $destinationPath = public_path() . $pixpath;
                 $filename = $user->username . '.' . $file->getClientOriginalExtension();
                 $file->move($destinationPath, $filename);
                 $user->picture = base64_encode($pixpath . $filename);
             }
             $user->save();
             return Redirect::to('login')->with('successmessage', trans('master.registersuccess'));
         }
     }
     return Redirect::route('register.index')->withInput()->withErrors($s->errors());
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:35,代码来源:RegisterController.php

示例12: postUploads

 public function postUploads()
 {
     $id = Auth::user()->id;
     // $file = Input::file('image');
     // $input = array('image' => $file);
     // $rules = array(
     // 	'image' => 'image'
     // );
     // $validator = Validator::make($input, $rules);
     // if ( $validator->fails() )
     // {
     // 	return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]);
     // }
     // else {
     if (Input::hasFile('image')) {
         $file = Input::file('image');
         //$destinationPath = 'uploads/' .$id;
         //$destinationPath = public_path().'/img/'.$id;
         $destinationPath = app_path() . '/foundation-5.4.0/profilePic/' . $id;
         $file->move($destinationPath, $id . '.JPEG');
         //Input::file('image')->move($destinationPath);
         // $ = 'uploads/';
         // $filename = $id;
         // Input::file('image')->move($destinationPath, $fileName);
         //Input::file('image')->move($destinationPath, $filename);
         //return Response::json(['success' => true, 'file' => asset($destinationPath.$filename)]);
         return Redirect::to('myprofile');
     } else {
         return 'no file';
     }
 }
开发者ID:Clare-E-Rich,项目名称:DECO7381_MoneyLink_GroupProject,代码行数:31,代码来源:ImageController.php

示例13: addPhotos

 public function addPhotos()
 {
     if (\Input::hasFile('image')) {
         $images = \Input::file('image');
         if (!$this->photoRepository->imagesMetSizes($images)) {
             return 0;
         }
         //confirm if one of the size is more than admin set value
         $event = $this->eventRepository->get(\Input::get('val.id'));
         $param = ['path' => 'events/' . $event->id . '/posts', 'slug' => 'photos', 'userid' => $event->user->id, 'event_id' => $event->id, 'privacy' => 5];
         $photos = [];
         $paths = [];
         foreach ($images as $im) {
             $i = $this->photoRepository->upload($im, $param);
             $paths[] = $i;
             $photos[] = $this->photoRepository->getByLink($i);
         }
         //help this event to post to its timeline
         $this->postRepository->add(['type' => 'event', 'content_type' => 'image', 'type_content' => $paths, 'event_id' => $event->id, 'privacy' => 1]);
         $content = "";
         foreach ($photos as $photo) {
             if ($photo) {
                 $content .= (string) $this->theme->section('photo.display-photo', ['photo' => $photo]);
             }
         }
         return $content;
     }
     return '0';
 }
开发者ID:adamendvy89,项目名称:intifadah,代码行数:29,代码来源:EventProfileController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $imageName = '';
     $imagePath = public_path() . '/img/';
     if (Input::hasFile('photo')) {
         $img = Input::file('photo');
         $imageName = str_random(6) . '_' . $img->getClientOriginalName();
         $img->move($imagePath, $imageName);
         $img = Image::make($imagePath . $imageName);
         $img->save($imagePath . $imageName);
         $thumb = Image::make($imagePath . $imageName);
         $thumbName = $imageName;
         $thumbPath = public_path() . '/thumbs/img/';
         $thumb->resize(100, 100);
         $thumb->save($thumbPath . $thumbName);
         $imgEntry = new Photo();
         $imgEntry->user_id = Auth::user()->id;
         $imgEntry->caption = Input::get('caption');
         $imgEntry->path = 'img/' . $imageName;
         $imgEntry->save();
         return Response::json(array('error' => false, 'message' => 'Upload successful.'), 200);
     } else {
         return Response::json(array('error' => 'true', 'photos' => null), 200);
     }
 }
开发者ID:jbrown25,项目名称:PhotoSharing-PHP-backend,代码行数:30,代码来源:PhotoController.php

示例15: apply

 public function apply($id)
 {
     $job = DB::select("EXEC spJobByID_Select @JobID = {$id}")[0];
     $data = [];
     $data['job'] = $job;
     $data['form'] = Input::all();
     $email = Input::get('email');
     $name = Input::get('name');
     if (Input::hasFile('cv')) {
         $newfilename = Str::slug($name) . '_cv_' . uniqid() . '.' . Input::file('cv')->getClientOriginalExtension();
         Input::file('cv')->move(public_path() . '/uploads/cvs/', $newfilename);
         Mail::send('emails.jobs.apply', $data, function ($message) use($email, $name, $newfilename, $job) {
             $message->to($email, $name)->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
             $message->bcc($job->OperatorEmail, $job->OperatorName . ' ' . $job->OperatorSurname)->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
             $message->attach(public_path() . '/uploads/cvs/' . $newfilename);
         });
     } else {
         // Send email to KDC
         Mail::send('emails.jobs.apply', $data, function ($message) use($email, $name, $job) {
             $message->to($email, $name)->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
             $message->bcc($job->OperatorEmail, $job->OperatorName . ' ' . $job->OperatorSurname)->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
             $message->bcc('it_support@kdc-group.co.uk', 'KDC')->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
         });
     }
     return Redirect::back()->withInfo('Your application has been sent');
 }
开发者ID:TheCompleteCode,项目名称:laravel-kdc,代码行数:26,代码来源:JobController.php


注:本文中的Input::hasFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。