unable to get file using fileupload jquery

≯℡__Kan透↙ 提交于 2020-12-15 04:33:34

问题


I am using JQuery fancyfileupload - https://github.com/cubiclesoft/jquery-fancyfileuploader, to save my form and its user inputs on sql. There are two files on my form. one which is with the plugin and the other is HTML file input. I am unable to get my HTML file input files to my backend although I am getting the inserted file through the plugin - demo.

<form id="NewOrder" action="order/add.php" method="post" autocomplete="off" enctype="multipart/form-data">
    <div class="col-lg-6">
        <div>
            <input id="ddnote" name="ddnote" type="file">
        </div>
    </div>
    <div>
    //FANCY UPLOAD FILE UPLOADER
        <div class="input-group mb-3">
            <input id="demo" type="file" name="image[]" accept=".jpg, .png, image/jpeg, image/png" multiple>
        </div>
    </div>
    <div class="col-lg-6">
        <div class="input-group mb-3">
            <textarea value="Note Text" id="note" name="note" class="form-control" placeholder="Note" rows="6"></textarea>
        </div>
    </div>
    <div class="col-lg-6">
        <div class="input-group mb-3">
            <input aria-label="oname" id="oname" name="oname" class="form-control" placeholder="Color" type="text">
        </div>
    </div>
    <div class="form-group mb-0 mt-3 justify-content-end">
        <div>
            <button id="add" type="submit" class="btn btn-primary btn-size">Add</button>
        </div>
    </div>
</form>

then the jquery goes as

<script>
    $(document).ready(function(){            
        var sendData= true;
        $("#demo").FancyFileUpload({
            dataType : 'json',
            retries: 0,
            autoUpload : false,
            processData: false,
            contentType: false,
            added : function(e,data){
                $("#add").on("click",function(){
                    if(sendData){
                        data.formData = $("#NewOrder").serializeArray();
                        sendData = false;
                    }
                    data.submit();
                    $('#NewOrder')[0].reset();
                });
            },
            done: function(e,data){
                sendData = true;
            }
        });
    });
</script>

I am getting all user inputs except the ddnote html5 file without the plugin. when I var_dump($_FILES) it doesn't include ddnote in it. Why is it? Please advice on this.

reference: https://stackoverflow.com/a/21282349/8006158

来源:https://stackoverflow.com/questions/64843423/unable-to-get-file-using-fileupload-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!