本文整理汇总了PHP中Input::file方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::file方法的具体用法?PHP Input::file怎么用?PHP Input::file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: postUpdate
public function postUpdate($id)
{
$archivo = Input::file('archivo');
$imagen = Input::file('imagen');
$validator = Validator::make(array('archivo' => $archivo, 'imagen' => $imagen), array('archivo' => 'mimes:png,jpeg,gif,txt,ppt,pdf,doc,xls', 'imagen' => 'mimes:png,jpeg,gif'), array('mimes' => 'Tipo de archivo inválido, solo se admite los formatos PNG, JPEG, y GIF'));
if ($validator->fails()) {
return Redirect::to($this->route . '/create')->with('msg_err', Lang::get('messages.companies_create_img_err'));
} else {
$arquivo = SFArquivos::find($id);
$arquivo->titulo_archivo = Input::get('titulo_archivo');
$arquivo->id_categoria = Input::get('id_categoria');
$arquivo->resumem = Input::get('resumem');
$arquivo->tipo_archivo = Input::get('tipo_archivo');
if ($archivo != "") {
$url = $archivo->getRealPath();
$extension = $archivo->getClientOriginalExtension();
$name = str_replace(' ', '', strtolower(Input::get('titulo_archivo'))) . date('YmdHis') . rand(2, 500 * 287) . '.' . $extension;
$size = $archivo->getSize();
$mime = $archivo->getMimeType();
$archivo->move(public_path('uploads/arquivos/'), $name);
$arquivo->archivo = $name;
}
if ($imagen != "") {
$imagen = $this->uploadHeader($imagen);
$arquivo->imagen = $imagen;
}
$arquivo->save();
return Redirect::to($this->route)->with('msg_success', Lang::get('messages.companies_create', array('title' => $arquivo->title)));
}
}
示例4: upload
/**
* Upload un torrent
*
* @access public
* @return View torrent.upload
*
*/
public function upload()
{
$user = Auth::user();
// Post et fichier upload
if (Request::isMethod('post')) {
// No torrent file uploaded OR an Error has occurred
if (Input::hasFile('torrent') == false) {
Session::put('message', 'You must provide a torrent for the upload');
return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
} else {
if (Input::file('torrent')->getError() != 0 && Input::file('torrent')->getClientOriginalExtension() != 'torrent') {
Session::put('message', 'An error has occurred');
return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
}
}
// Deplace et decode le torrent temporairement
TorrentTools::moveAndDecode(Input::file('torrent'));
// Array from decoded from torrent
$decodedTorrent = TorrentTools::$decodedTorrent;
// Tmp filename
$fileName = TorrentTools::$fileName;
// Info sur le torrent
$info = Bencode::bdecode_getinfo(getcwd() . '/files/torrents/' . $fileName, true);
// Si l'announce est invalide ou si le tracker et privée
if ($decodedTorrent['announce'] != route('announce', ['passkey' => $user->passkey]) && Config::get('other.freeleech') == true) {
Session::put('message', 'Your announce URL is invalid');
return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
}
// Find the right category
$category = Category::find(Input::get('category_id'));
// Create the torrent (DB)
$torrent = new Torrent(['name' => Input::get('name'), 'slug' => Str::slug(Input::get('name')), 'description' => Input::get('description'), 'info_hash' => $info['info_hash'], 'file_name' => $fileName, 'num_file' => $info['info']['filecount'], 'announce' => $decodedTorrent['announce'], 'size' => $info['info']['size'], 'nfo' => Input::hasFile('nfo') ? TorrentTools::getNfo(Input::file('nfo')) : '', 'category_id' => $category->id, 'user_id' => $user->id]);
// Validation
$v = Validator::make($torrent->toArray(), $torrent->rules);
if ($v->fails()) {
if (file_exists(getcwd() . '/files/torrents/' . $fileName)) {
unlink(getcwd() . '/files/torrents/' . $fileName);
}
Session::put('message', 'An error has occured may bee this file is already online ?');
} else {
// Savegarde le torrent
$torrent->save();
// Compte et sauvegarde le nombre de torrent dans cette catégorie
$category->num_torrent = Torrent::where('category_id', '=', $category->id)->count();
$category->save();
// Sauvegarde les fichiers que contient le torrent
$fileList = TorrentTools::getTorrentFiles($decodedTorrent);
foreach ($fileList as $file) {
$f = new TorrentFile();
$f->name = $file['name'];
$f->size = $file['size'];
$f->torrent_id = $torrent->id;
$f->save();
unset($f);
}
return Redirect::route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with('message', trans('torrent.your_torrent_is_now_seeding'));
}
}
return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
}
示例5: updateProfile
public function updateProfile()
{
$name = Input::get('name');
//$username = Input::get('username');
$birthday = Input::get('birthday');
$bio = Input::get('bio', '');
$gender = Input::get('gender');
$mobile_no = Input::get('mobile_no');
$country = Input::get('country');
$old_avatar = Input::get('old_avatar');
/*if(\Cashout\Models\User::where('username',$username)->where('id','!=',Auth::user()->id)->count()>0){
Session::flash('error_msg', 'Username is already taken by other user . Please enter a new username');
return Redirect::back()->withInput(Input::all(Input::except(['_token'])));
}*/
try {
$profile = \Cashout\Models\User::findOrFail(Auth::user()->id);
$profile->name = $name;
// $profile->username = $username;
$profile->birthday = $birthday;
$profile->bio = $bio;
$profile->gender = $gender;
$profile->mobile_no = $mobile_no;
$profile->country = $country;
$profile->avatar = Input::hasFile('avatar') ? \Cashout\Helpers\Utils::imageUpload(Input::file('avatar'), 'profile') : $old_avatar;
$profile->save();
Session::flash('success_msg', 'Profile updated successfully');
return Redirect::back();
} catch (\Exception $e) {
Session::flash('error_msg', 'Unable to update profile');
return Redirect::back()->withInput(Input::all(Input::except(['_token', 'avatar'])));
}
}
示例6: update
public function update($id)
{
$validator = Validator::make(array('slider' => Input::file('slider')), array("slider" => "image | mimes:jpeg, jpg, png, gif | max: 6000"), array('mimes' => '<span class="glyphicon glyphicon-remove"></span> Unknown file inserted', 'size' => '<span class="glyphicon glyphicon-exclamation-sign"></span> Size must be less than 6 MB'));
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
} else {
if (Input::file('slider') != '') {
$file = Input::file('slider');
$name = date('i-G-Y') . $file->getClientOriginalName();
$destination = 'assets/images/slider/';
$file->move($destination, $name);
$query = Slider::find($id);
$query->slider = 'assets/images/slider/' . $name;
$query->slider_text = Input::get('text');
if ($query->save()) {
return Redirect::route('slider-page')->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Slider updated successfully</p>');
} else {
return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error occured. Please try after sometime</p>');
}
} else {
$query = Slider::find($id);
$query->slider_text = Input::get('text');
if ($query->save()) {
return Redirect::route('slider-page')->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Slider updated successfully</p>');
} else {
return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error occured. Please try after sometime</p>');
}
}
}
}
示例7: 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();
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$file = array('image' => Input::file('image'));
// setting up rules
$rules = array('image' => 'required|mimes:jpeg,gif');
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules);
// process the login
if ($validator->fails()) {
return Redirect::to('images/create')->withErrors($validator)->withInput(Input::except('password'));
} else {
// store
// $userId = Auth::user()->id;
// $file = Input::file('image');
// $data = Img::make($file)->encode('data-url');
//
// $this->image->user_id = $userId;
// $this->image->img_name = $data->encoded;
// $this->image->save();
$file = Input::file('image');
$picture = $file->getClientOriginalName();
$generatepic = rand(32321323, 8687868678) . $picture;
$fullpath = $file->move('../public/img', $generatepic);
$images = new Images();
$images->image = $fullpath;
// $images->image = Input::file('image')->getClientOriginalName();
$images->save();
// redirect
Session::flash('message', 'Successfully uploaded!');
return Redirect::to('images');
}
}
示例9: store
/**
* Stores new account
*
* @return Illuminate\Http\Response
*/
public function store()
{
$repo = App::make('UserRepository');
$user = $repo->signup(Input::all());
if ($user->id) {
if (Config::get('confide::signup_email')) {
Mail::queueOn(Config::get('confide::email_queue'), Config::get('confide::email_account_confirmation'), compact('user'), function ($message) use($user) {
$message->to($user->email, $user->first_name)->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
});
}
return Redirect::action('UsersController@login')->with('notice', Lang::get('confide::confide.alerts.account_created'));
} else {
$error = $user->errors()->all(':message');
return Redirect::action('UsersController@create')->withInput(Input::except('password'))->with('error', $error);
}
$input = array('image' => Input::file('image'));
$rules = array('image' => 'image');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($e->getErrors());
} else {
$file = Input::file('image');
$name = time() . '-' . $file->getClientOriginalName();
$file = $file->move('uploads/', $name);
$input['file'] = '/public/uploads/' . $name;
}
}
示例10: store
/**
* Store a newly created resource in storage.
* POST /estudios
*
* @return Response
*/
public function store()
{
//check for a file
if (!Input::hasFile('Filedata')) {
return 'No file.';
}
//nuevo archivo
$now = Carbon::now();
$code = $now->timestamp;
$file = $code . '.' . Input::file('Filedata')->getClientOriginalExtension();
if (Input::file('Filedata')->move(public_path() . '/media', $file)) {
$nueva = new Post();
$nueva->titulo = Input::get('titulo');
$nueva->tipo = 1;
$nueva->categoria = 1;
$nueva->fecha_publicacion = Carbon::now();
$nueva->attachment = $file;
$nueva->imagen = '';
$nueva->subtitulo = '';
$nueva->descripcion = Input::get('descripcion');
$nueva->save();
return '1';
} else {
return 'Invalid file type.';
}
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @return Response
* @throws ImageFailedException
* @throws \BB\Exceptions\FormValidationException
*/
public function store()
{
$data = \Request::only(['user_id', 'category', 'description', 'amount', 'expense_date', 'file']);
$this->expenseValidator->validate($data);
if (\Input::file('file')) {
try {
$filePath = \Input::file('file')->getRealPath();
$ext = \Input::file('file')->guessClientExtension();
$mimeType = \Input::file('file')->getMimeType();
$newFilename = \App::environment() . '/expenses/' . str_random() . '.' . $ext;
Storage::put($newFilename, file_get_contents($filePath), 'public');
$data['file'] = $newFilename;
} catch (\Exception $e) {
\Log::error($e);
throw new ImageFailedException($e->getMessage());
}
}
//Reformat from d/m/y to YYYY-MM-DD
$data['expense_date'] = Carbon::createFromFormat('j/n/y', $data['expense_date']);
if ($data['user_id'] != \Auth::user()->id) {
throw new \BB\Exceptions\FormValidationException('You can only submit expenses for yourself', new \Illuminate\Support\MessageBag(['general' => 'You can only submit expenses for yourself']));
}
$expense = $this->expenseRepository->create($data);
event(new NewExpenseSubmitted($expense));
return \Response::json($expense, 201);
}
示例12: file_move
public function file_move()
{
if (Input::hasFile('image')) {
$vote_id_temp = Session::get('vote_id_insert', '');
$this->clean($vote_id_temp);
$file = Input::file('image');
//
$fileName = "test222";
$destinationPath = storage_path() . '/file_import/';
$file = $file->move($destinationPath, $fileName);
Excel::selectSheetsByIndex(0)->load($file, function ($reader) use($vote_id_temp) {
//以第一個資料表中的資料為主
//提醒使用ooo的使用者,不要存成 Microsoft Excel 95
//需存成 Microsoft Excel 97/2000/xp ***.xls
$value = $reader->get()->toArray();
//object -> array
foreach ($value as $data_array1) {
//$vote_id_temp = Session::get('vote_id_insert', '');
$data_array1['vote_id'] = $vote_id_temp;
//var_dump($data_array1);
$candidate = Candidate::create($data_array1);
// $candidate = new Candidate;
// $candidate->cname=$data_array1[0];
// $candidate->job_title=$data_array1[1];
// $candidate->sex=$data_array1[2];
// $candidate->vote_id=42;
// $candidate->total_count=0;
// $candidate->save();
}
});
// echo $file;
//File::delete($file);
}
return Redirect::route('votes_not_yet');
}
示例13: upload
public function upload()
{
$file = Input::file('file');
$input = array('image' => $file);
$rules = array('image' => 'image');
$validator = Validator::make($input, $rules);
$imagePath = 'public/uploads/';
$thumbPath = 'public/uploads/thumbs/';
$origFilename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$mimetype = $file->getMimeType();
if (!in_array($extension, $this->whitelist)) {
return Response::json('Supported extensions: jpg, jpeg, gif, png', 400);
}
if (!in_array($mimetype, $this->mimeWhitelist) || $validator->fails()) {
return Response::json('Error: this is not an image', 400);
}
$filename = str_random(12) . '.' . $extension;
$image = ImageKit::make($file);
//save the original sized image for displaying when clicked on
$image->save($imagePath . $filename);
// make the thumbnail for displaying on the page
$image->fit(640, 480)->save($thumbPath . 'thumb-' . $filename);
if ($image) {
$dbimage = new Image();
$dbimage->thumbnail = 'uploads/thumbs/thumb-' . $filename;
$dbimage->image = 'uploads/' . $filename;
$dbimage->original_filename = $origFilename;
$dbimage->save();
return $dbimage;
} else {
return Response::json('error', 400);
}
}
示例14: 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");
}
}
示例15: 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!');
}