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

    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮