Input
Input
Please note that both Input and Request do NOT sanitize your data, it is up to you to do that.
Basic Input
You may access all user input with a few simple methods. You do not need to worry about the HTTP verb used for the request, as input is accessed in the same way for all verbs.
Retrieving An Input Value
$name = Input::get('name');
Retrieving A Default Value If The Input Value Is Absent
$name = Input::get('name', 'Sally');
Determining If An Input Value Is Present
if (Input::has('name'))
{
//
}
Getting All Input For The Request
$input = Input::all();
Getting Only Some Of The Request Input
$input = Input::only('username', 'password');
$input = Input::except('credit_card');
When working on forms with "array" inputs, you may use dot notation to access the arrays:
$input = Input::get('products.0.name');
Note: Some JavaScript libraries such as Backbone may send input to the application as JSON. You may access this data via Input::get like normal.
Old Input
You may need to keep input from one request until the next request. For example, you may need to re-populate a form after checking it for validation errors.
Flashing Input To The Session
Input::flash();
Flashing Only Some Input To The Session
Input::flashOnly('username', 'email');
Input::flashExcept('password');
Since you often will want to flash input in association with a redirect to the previous page, you may easily chain input flashing onto a redirect.
return Redirect::to('form')->withInput();
return Redirect::to('form')->withInput(Input::except('password'));
Note: You may flash other data across requests using the Session class.
Retrieving Old Data
Input::old('username');
Files
Retrieving An Uploaded File
$file = Input::file('photo');
Determining If A File Was Uploaded
if (Input::hasFile('photo'))
{
//
}
The object returned by the file method is an instance of the Symfony\Component\HttpFoundation\File\UploadedFile class, which extends the PHP SplFileInfo class and provides a variety of methods for interacting with the file.
Determining If An Uploaded File Is Valid
if (Input::file('photo')->isValid())
{
//
}
Moving An Uploaded File
Input::file('photo')->move($destinationPath);
Input::file('photo')->move($destinationPath, $fileName);
Retrieving The Path To An Uploaded File
$path = Input::file('photo')->getRealPath();
Retrieving The Original Name Of An Uploaded File
$name = Input::file('photo')->getClientOriginalName();
Retrieving The Extension Of An Uploaded File
$extension = Input::file('photo')->getClientOriginalExtension();
Retrieving The Size Of An Uploaded File
$size = Input::file('photo')->getSize();
Retrieving The MIME Type Of An Uploaded File
$mime = Input::file('photo')->getMimeType();
Input的更多相关文章
- HTML中上传与读取图片或文件(input file)----在路上(25)
input file相关知识简例 在此介绍的input file相关知识为: 上传照片及文件,其中包括单次上传.批量上传.删除照片.增加照片.读取图片.对上传的图片或文件的判断,比如限制图片的张数.限 ...
- HTML5 input元素新的特性
在HTML5中,<input>元素增加了许多新的属性.方法及控件.本文章分别对这三方面进行介绍. 目录 1. 属性 2. 方法 3. 新控件 1. 属性 <input>元素在H ...
- input[tyle="file"]样式修改及上传文件名显示
默认的上传样式我们总觉得不太好看,根据需求总想改成和上下结构统一的风格…… 实现方法和思路: 1.在input元素外加a超链接标签 2.给a标签设置按钮样式 3.设置input[type='file' ...
- input标签中button在iPhone中圆角的问题
1.问题 使用H5编写微信页面时,使用<input type="button"/>时,在Android手机中显示正常,但是在iPhone手机中则显示不正常,显示为圆角样 ...
- input type='file'上传控件假样式
采用bootstrap框架样式 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> &l ...
- css3更改input单选和多选的样式
在项目开发中我们经常会遇到需要更改input单选和多选样式的情况,今天就给大家介绍一种简单改变input单选和多选样式的办法. 在这之前先简单介绍一下:before伪类 :before 选择器向选定的 ...
- css样式让input垂直居中
css样式让input垂直居中 css代码: .div1{ border: 1px solid #CCC; width:1120px; height:40px; margin:auto; displa ...
- jQuery选择器中,通配符[id^='code']input[id$='code'][id*='code']
1.选择器 (1)通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']&qu ...
- 解决手机浏览器上input 输入框导致页面放大的问题(记录)
在微信手机页面开发当中,页面是没有问题的,但是当焦点在input输入框的时候,手机页面会自动放大. 加入以下代码在head 区,可解决此问题 <meta name="viewport& ...
- <input type="file">上传文件并添加路径到数据库
注:这里是用的mvc所以没法用控件 html代码 <form method="post" enctype="multipart/form-data"> ...
随机推荐
- 【转】提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果
原文网址:http://www.zhimengzhe.com/IOSkaifa/37910.html MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单.方便,并且可以对显 ...
- 【转】开发者教程:如何将Android应用发布到Google Play(Android Market)官方市场
原文网址:http://www.chinaapp.org/game/5594.html 作为一个专业的App开发者网站,竟然没有一篇讲述如何将Android App发布到Google Play的教程, ...
- MongoDB之二基础入门(安装启动)
mongodb中有三元素:数据库,集合,文档,其中“集合” 就是对应关系数据库中的“表”,“文档”对应“行”. 一. 下载 上MongoDB官网 ,我们发现有32bit和64bit,这个就要看你系统了 ...
- HW6.17
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- Javascript and DOM学习
1.输出 document.write.(); 2.alert警告 3.confirm消息对话框:当用户点击"确定"按钮时,返回true,取消时,返回false 4.prompt提 ...
- leetcode@ [72/115] Edit Distance & Distinct Subsequences (Dynamic Programming)
https://leetcode.com/problems/edit-distance/ Given two words word1 and word2, find the minimum numbe ...
- hdoj 2050 折线分割平面
折线分割平面 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- 超级MINI STLINK V2 官方固件自动升级 ST-Link 【worldsing 笔记】
简介: 支持所有带SWIM接口的STM8系列单片机 支持所有带SWD接口的STM32系列单片机 完全兼容Keil,STVP,STVD,IAR,COSMIC,STM32 ST-LINK Utility! ...
- (5)RARP:逆地址解析协议
一.简介 无盘系统的RARP实现过程是从接口卡上读取唯一的硬件地址,然后发送一份RARP请求(一帧在网络上广播的数据),请求某个主机响应该无盘系统的IP地址(在RARP应答中).感觉这个过程和上一章中 ...
- 【Stage3D学习笔记续】山寨Starling(三):Starling核心渲染流程
这篇文章我们剔除Starling的Touch事件体系和动画体系,专门来看看Starling中的渲染流程实现,以及其搭建的显示列表结构. 由于Starling是模仿Flash的原生显示列表,所以我们可以 ...