php - 使用 laravel 和 mamp 将较大的文件上传到 mysql 数据库时无法连接
问题描述
我在将文件上传到我的 apache 服务器时遇到问题,导航器不断显示连接已重置的消息。我试过小文件(100kb),它工作得很好,但是当我尝试500kb或更多文件时,连接被重置了......
这是我的 php.ini 上传设置:
upload_max_filesize = 320M
memory_limit = 12800M
最大输入时间 = 6000
max_execution_time = 3000
post_max_size = 300M
default_socket_timeout = 600
表格代码:
<form enctype="multipart/form-data" method="POST" action="{{ url('FruitCreate') }}" >
{{ csrf_field() }}
<input type="text" name='name'>
<input type="text" name='price'>
<input type="hidden" name="MAX_FILE_SIZE" value="30000000" />
<input type="file" name='image'>
<select name='quantitytype'>
<option value='unity'> unity </option>
<option value='kg'> kg </option>
</select>
<button type='submit'> submit </button>
这是我的控制器,用于在 db 中输入新行:
class fruitController extends Controller
public function createFruit(Request $request){
$file = $request->file('image');
$fruit = new fruit;
$imageContent = $file->openFile()->fread($file->getSize());
$fruit = new fruit;
$fruit->picture = $imageContent;
$fruit->name = $request->name;
$fruit->quantitytype = $request->quantitytype;
$fruit->price = $request->price;
$fruit->save();
return redirect('FruitsChangingPricePanel');
//
谢谢你的帮助 !!!!!
解决方案
推荐阅读
- python - 具有相同行和列的 Tkinter 网格布局管理器行为是什么?
- kotlin - Kotlin 根据另一个列表过滤列表
- java - android PhoneStateListener onCallStateChanged 奇怪的行为
- angular - 'Observable<> 类型上不存在属性 'filter'
- ios - 拍照后如何暂停?
- javascript - 立即更改语言环境不要相应地刷新 vuejs 组件
- .net - 当我部署到我的服务器时,HttpContext.Current.Server 引发了 System.NullReferenceException 类型的异常
- java - 如何获取文件路径
- java - 运行时的外部数据加载
- python - 如何在 python 中停止循环迭代