【发布时间】:2016-09-17 23:15:57
【问题描述】:
我正在尝试将表单内的文件提交到 Laravel 后端。它发布所有其他文本字段,但不发布文件(当我 dd($request->all()) 时)
<form class="form-horizontal" role="form" method="POST" action="" enctype="multipart/form-data">
<input id="item_price" type="item_price" class="form-control" name="item_price" value="">
<!-- other inputs -->
<input type="file" id="product_image" name="product_image" onchange="previewImage(this);"/>
<img id="previewing" src="{{asset('noImage.gif')}}" style="width: 100%; height: 100%" />
</form>
item_price 出现在 dd($request->all()) 上,还看到其他字段,但没有文件输入
当我在提交表单之前使用 jQuery (previewImage) 显示图像时,它会显示照片。但是在我提交表单后,在 Laravel 端它会显示所有其他字段和值,但不会显示任何文件(当我使用 dd($request->all()) 时。
在php.ini 上,max-post-size 为 100M。
jQuery('#previewing').click(function() {
uploadImageClicked();
});
function uploadImageClicked() {
jQuery('#product_image').click();
}
dd($request->hasFile('product_image') 返回错误
【问题讨论】:
标签: php html forms laravel post