如何在Laravel 5中通过干预图像上传大尺寸图像 [英] How to upload large size image by Intervention Image in Laravel 5
问题描述
我在项目中使用的是图像干预.
我的应用程序在上传小尺寸图像时运行正常.但是,当我尝试上传大尺寸图片(> 2mb)时,我的应用程序停止运行!
My application working smoothly while uploading small size images. But when I try to upload large size image(>2mb), my application stops working!
即使没有显示正确的错误.有时它显示Token mismatch
错误&有时网址无法重定向.
Even It shows no proper errors. Sometimes It shows Token mismatch
error & sometimes the url not redirects.
如何解决?我不知道.
这是我的代码:
$post->new Post();
if($request->hasFile('image')){
$image=$request->file('image');
$filename=Auth::user()->id.'_'.time().'.'.$image->getClientOriginalExtension();
$location=public_path('images/'.$filename);
Image::make($image)->save($location);
$post->image=$filename;
}
$post->save();
我正在使用Image intervention
上载图像.但是您也可以提出其他建议.
I'm using Image intervention
for uploading images. But you can suggest alternative of it as well.
谢谢!
推荐答案
实际上,这是服务器端在php.ini
文件中设置变量值的问题.如果上传更多文件,则服务器的post_max_size设置输入为空,则会出现令牌不匹配错误.
Actually this is the issue from server side setting variable values into php.ini
file. if you upload more then your server's post_max_size setting the input will be empty, you will get Token mismatch error.
根据需要更改upload_max_filesize
,post_max_size
值,然后重新启动服务器.
change upload_max_filesize
, post_max_size
value as per you required and restart the server.
这篇关于如何在Laravel 5中通过干预图像上传大尺寸图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!