dsgk40568 2016-09-17 19:51
浏览 31

Input :: file('fileInput')不检测File

I have an individual html form for uploading photo on Laravel's blade and I am trying to post the image to the Controller.

The Html form looks like:

<form id="fileForm" enctype="multipart/form-data">
    <input type="file" id="fileInput" name="fileInput" style="visibility: hidden"/>
    <input type="button" value="submit" id="ajaxSubmit" hidden />
</form>

And in (document.ready):

  jQuery('input[type=file]').change(function() {
       jQuery('#fileForm').submit();
  });


  jQuery('#fileForm').on('submit',(function(e) {
       e.preventDefault();

       jQuery.ajax({
           url: '',
           type: 'POST',
           data: new FormData(jQuery(this)[0]),
           processData: false,
           success: function (data) {

           },
           complete: function() {

           }
        })
  }))

When I dd(Input:all()); on the controller, it shows this and so on:

enter image description here

However, dd(Input::file('fileInput)) returns null.

When I try dd(Input::hasFile('fileForm')); (which I feel it is not correct), it returns false

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程