doushao6874 2019-06-18 10:09
浏览 149

Dropzone多文件上传不适用于Excel文件

I have facing a problem in Dropzone and Laravel 5.7. I am currently upload excel file to via dropzone. But it is not working correctly. For example If I add 10 files then In my database there is 10 entry with different file name but On file Storage folder there are not 10 files, It varies from 6,7,8 File. I am changing my php.ini file for upload_max_filesize and max_file_uploads. Here is my code snippet. My Js Code

<script type="text/javascript">
    Dropzone.options.dropzone =
        {
            parallelUploads: 1, // Uploads one (1) file at a time, change to whatever you like.
            autoProcessQueue: true,
            uploadMultiple: true,
            maxFiles: 100,
            maxFilesize: 3,
            autoQueue: true,
            renameFile: function (file) {
                var dt = new Date();
                var time = dt.getTime();
                return time + file.name;
            },
            addRemoveLinks: true,
            timeout: 50000,
            removedfile: function (file)
            {
                var name = file.upload.filename;
                $.ajax({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                    },
                    type: 'POST',
                    url: '{{ url("admin.pos.deleteexcel") }}',
                    data: {filename: name},
                    success: function (data) {
                        console.log("File has been successfully removed!!");
                    },
                    error: function (e) {
                        console.log(e);
                    }});
                var fileRef;
                return (fileRef = file.previewElement) != null ?
                        fileRef.parentNode.removeChild(file.previewElement) : void 0;
            },
            success: function (file, response)
            {
                console.log(response);
            },
            error: function (file, response)
            {
                return false;
            }
        };
</script>

My Form is

{!! Form::open(['method'=>'POST', 'action'=>'backend\ExcelController@multipleExcelStore', 'files'=>true, 'id' => 'dropzone_form', 'class'=>'dropzone needsclick dz-clickable']) !!}
        <div class="dz-message needsclick">
            <div class="search-block">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="upload_container">
                            <div class="upbtn_block_1">
                                Drag &amp; drop Files Here
                            </div><!--/upbtn_block_1 -->
                            <div class="up_text_block">Or</div>
                            <div class="upload_btn"><span>Browse File</span></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {!! Form::close() !!}

And My controller code

public function multipleExcelStore(Request $request) {
    $input = [];
    $imageName = Carbon::now()->format('Y') . '/' . Carbon::now()->format('m') . '/' . uniqid() . '_' . time() . '.' . $request->file('file')->getClientOriginalExtension();
    $destinationPath = Config::get('constants.PO_MULTILE_ATTACHEMNT') . '/';
    Helper::uploadFile($request->file('file'), null, $destinationPath, $imageName);
    $input['attachment'] = Config::get('constants.PO_MULTILE_ATTACHEMNT') . '/' . $imageName;
    $input['process_user_id'] = Auth::guard('admin')->user()->id;
    $input['process_ip'] = $request->ip();
    $input['name'] = $request->file('file')->getClientOriginalName();
    PosExcel::create($input);
    return response()->json(['success' => $imageName]);
}

I google it but return without any success. Thank You

  • 写回答

1条回答 默认 最新

  • drkug66408 2019-06-18 10:42
    关注

    Have you tryed to remove

    autoProcessQueue: true,
                uploadMultiple: true,
    

    I have another project with multiple upload and dont need to use that argument in the javascript, Queue is possible that is the problem too, try it and tell us :)

    good luck

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集