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的更多相关文章

  1. HTML中上传与读取图片或文件(input file)----在路上(25)

    input file相关知识简例 在此介绍的input file相关知识为: 上传照片及文件,其中包括单次上传.批量上传.删除照片.增加照片.读取图片.对上传的图片或文件的判断,比如限制图片的张数.限 ...

  2. HTML5 input元素新的特性

    在HTML5中,<input>元素增加了许多新的属性.方法及控件.本文章分别对这三方面进行介绍. 目录 1. 属性 2. 方法 3. 新控件 1. 属性 <input>元素在H ...

  3. input[tyle="file"]样式修改及上传文件名显示

    默认的上传样式我们总觉得不太好看,根据需求总想改成和上下结构统一的风格…… 实现方法和思路: 1.在input元素外加a超链接标签 2.给a标签设置按钮样式 3.设置input[type='file' ...

  4. input标签中button在iPhone中圆角的问题

    1.问题 使用H5编写微信页面时,使用<input type="button"/>时,在Android手机中显示正常,但是在iPhone手机中则显示不正常,显示为圆角样 ...

  5. input type='file'上传控件假样式

    采用bootstrap框架样式 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> &l ...

  6. css3更改input单选和多选的样式

    在项目开发中我们经常会遇到需要更改input单选和多选样式的情况,今天就给大家介绍一种简单改变input单选和多选样式的办法. 在这之前先简单介绍一下:before伪类 :before 选择器向选定的 ...

  7. css样式让input垂直居中

    css样式让input垂直居中 css代码: .div1{ border: 1px solid #CCC; width:1120px; height:40px; margin:auto; displa ...

  8. jQuery选择器中,通配符[id^='code']input[id$='code'][id*='code']

     1.选择器 (1)通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']&qu ...

  9. 解决手机浏览器上input 输入框导致页面放大的问题(记录)

    在微信手机页面开发当中,页面是没有问题的,但是当焦点在input输入框的时候,手机页面会自动放大. 加入以下代码在head 区,可解决此问题 <meta name="viewport& ...

  10. <input type="file">上传文件并添加路径到数据库

    注:这里是用的mvc所以没法用控件 html代码 <form method="post" enctype="multipart/form-data"> ...

随机推荐

  1. Window.Event.KeyCode=13

    Window.Event.KeyCode=13是enter键处发windows事件,enter键的ASCII是13. <input type="password" name= ...

  2. 基于WebForm+EasyUI的业务管理系统形成之旅 -- 施工计划查询(Ⅷ)

    上篇<基于WebForm+EasyUI的业务管理系统形成之旅 -- 施工计划安排>,主要介绍整个施工计划列表与编辑界面. 下面看看施工计划查询(ⅠⅡⅢ ⅣⅤⅥ Ⅶ Ⅷ) 一.施工计划查询 ...

  3. HDU 5696 区间的价值 暴力

    分析:枚举以该点为最小值,然后找到最大值,更新,相应数组,至此,把区间分割(因为包含这个最小值点已经枚举过) 然后理解理解,感觉好像挺对的...因为后面(即dfs区间变小时)如果再包含最小值节点,也不 ...

  4. [原创]一种简单的cocos2d-x动态更新方案

    介绍一个曾经在cocos2d-x项目中使用过的动态更新方案,这个方案简单易行,针对小的项目非常有用. 这个方案有两个核心的关键词:JSON,MD5. 原理可以简单地概括为:服务端持有所有动态更新资源文 ...

  5. The usage method of reference with bibtex in Latex【latex中参考文献的使用方法】

    如何在latex中以Bibtex文件方式引用参考文献? 以IEEEtran模板为例: 1.制作bibtex参考文献库.方法如下: ①建立myreference.bib文件: ②在Google scho ...

  6. 【C语言】-选择结构-if语句

    if语句:也可称条件语句,是根据所给定条件的值是真还是假决定执行不同的分支. if语句有单分支.双分支.多分支以及if语句的嵌套等多种形式. 单分支if语句: if (条件表达式) { 语句组1; } ...

  7. DTD - XML Building Blocks

    The main building blocks of both XML and HTML documents are elements. The Building Blocks of XML Doc ...

  8. FreeModbus Slave 改进的eMbPoll()【worldsing 笔记】

    eMbPoll()的作用是FreeMod协议通信过程中不断查询事件对列有无完速数据桢,并进行地址和CRD验证,最后运行和回复主机. 为了减小代码尺寸对eMbPoll进行改进: 原版: 1:  2: e ...

  9. [css]inline-block

    能被父容器居中.能设置高度宽度和margin.不会像table或div那样占一正行……——这就是inline-block——记得这是浏览器默认样式告诉你的.

  10. 没有指针的java语言

    一.java中引用(reference)实质就是指针 与C语言的指针比较: 1.引用是受控的安全的 2.空引用会被检查 java中不能够访问没有引用到的内存,这也是java的自动垃圾回收机制的基础之一 ...