首页 > 解决方案 > 使用 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');
//

谢谢你的帮助 !!!!!

标签: phpmysqllaravelapachemamp

解决方案


推荐阅读