Save input into Parse (Javascript)

后端 未结 3 865
一整个雨季
一整个雨季 2021-01-21 17:23

Currently when the user select a file, it gets directly uploaded into Parse. I have added now couple input text field such as name of individual, address that I would want to be

3条回答
  •  爱一瞬间的悲伤
    2021-01-21 17:52

    You have "documentFileUpload" twice:

    Change:




    To:




    Edit

    To answer your comment about the recording of the UserId and Address fields, please see the following code. I changed the file upload binding to the button and bound the click event. This will fix your file uploading on selection.

    Also, added the id's user_id, and address to allow jQuery to get the values from those fields:

    $('#documentFileUploadButton').bind("click", function (e) {
            var fileUploadControl = $("#documentFileUpload")[0];
            var file = fileUploadControl.files[0];
            var name = file.name; //This does *NOT* need to be a unique name
            var parseFile = new Parse.File(name, file);
    
            var user_id = $('#user_id').val();
    
            var address = $('#address').val();
    
            parseFile.set('UserId', user_id);
            parseFile.set('Address', address);
    
            parseFile.save().then(
                    function () {
                        saveDocumentUpload(parseFile);
                    },
                    function (error) {
                        alert("error");
                    }
            );
        });
    

    And then:




提交回复
热议问题