GithubHelp home page GithubHelp logo

Comments (3)

hayageek avatar hayageek commented on August 17, 2024

I need to implement the feature. I will let you know once it is done.

from jquery-upload-file.

anizen avatar anizen commented on August 17, 2024

@hayageek

Please see.
I've implemented so.
but, Not perfect.
There is a part that was custom to match my file.

    function serializeAndUploadFiles(s, obj, files) {
        var i = 0;

        s.onSuccess = function (files, data, xhr) {
        // success event callback

        /* MY custom Source std */
        //insert image.
        jQuery('#sortable').append(data);

        /* MY custom Source end*/

        return loop();
        };

        function loop(){
            if(i<files.length){
                body();
            }
            i++;
        }

        function body(){
            if (!isFileTypeAllowed(obj, s, files[i].name)) {
                if (s.showError) alert(s.extErrorStr + s.allowedTypes);
                //$("<div style='color:red;'><b>" + files[i].name + "</b> " + s.extErrorStr + s.allowedTypes + "</div>").appendTo(obj.errorLog);
                return false;
                //continue;
            }
            if (s.maxFileSize != -1 && files[i].size > s.maxFileSize) {
                if (s.showError) alert(s.sizeErrorStr + 'once file '+getSizeStr(s.maxFileSize)+' not over');
                return false;
                //$("<div style='color:red;'><b>" + files[i].name + "</b> " + s.sizeErrorStr + getSizeStr(s.maxFileSize) + "</div>").appendTo(obj.errorLog);
                //continue;
            }
            var ts = s;
            var fd = new FormData();
            var fileName = s.fileName.replace("[]", "");
            fd.append(fileName, files[i]);

            fd.append('module','editor');
            fd.append('act','procEditorCall');
            fd.append('component',init('component'));
            fd.append('method','insertImage');
            fd.append('editor_sequence',init('editor_sequence'));

            var extraData = s.formData;

            if (extraData) {
                var sData = serializeData(extraData);
                for (var j = 0; j < sData.length; j++) {
                    if (sData[j]) {
                        fd.append(sData[j][0], sData[j][1]);
                    }
                }
            }
            ts.fileData = fd;

            var pd = new createProgressDiv(obj, s);
            var fileNameStr="";
            if(s.showFileCounter)
                fileNameStr = obj.fileCounter + s.fileCounterStyle + files[i].name
            else
                fileNameStr = files[i].name;

            pd.filename.html(fileNameStr);
            var form = $("<form style='display:block; position:absolute;left: 150px;' class='" + obj.formGroup + "' method='" + s.method + "' action='" + s.url + "' enctype='" + s.enctype + "'></form>");
            form.appendTo('body');
            var fileArray = [];
            fileArray.push(files[i].name);
            ajaxFormSubmit(form, ts, pd, fileArray, obj);
            obj.fileCounter++;
        }

        return loop();

    }

from jquery-upload-file.

hayageek avatar hayageek commented on August 17, 2024

Thanks i will add the feature to plugin

from jquery-upload-file.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.