Laravel基本上具有以下input类型的功能file.
// Determine if a file was uploaded
Input::hasFile('filename');
// Access file properties
Input::file('name')->getRealPath();
Input::file('name')->getClientOriginalName();
Input::file('name')->getClientOriginalExtension();
Input::file('name')->getSize();
Input::file('name')->getMimeType();
Run Code Online (Sandbox Code Playgroud)
如果我getClientOriginalExtension用来找到正确的图像扩展名,getSize限制文件上传大小和getMimeType检查图像的mimetype.
我安全吗?并且可以对功能有信心,它不会被黑客以任何方式利用.
考虑到一个事实,我将只上传图像.
http://php.w3clan.com/tutorial/47/form-handling-secure-uploading
$rule = [ 'name' => 'image' ];