как преобразовать загруженное изображение в байтовый массив javascript - PullRequest
0 голосов
/ 17 февраля 2020
i want to upload images to the server using ajax post request , here my question was how to convert image to a byte array for sending image to the server as multipart how can i achieve this.


here I posted what I tried:

<div class="col-sm-6 col-md-4 form-group">
                            <label>Attachement</label>
                            <input id="other_fileUpload_create" type="file" class="form-pcontrol">
                        </div>

Ajax:

  var formData = new FormData();
        $.ajax({
            url: baseURL + '/misportal/ptwRest/saveIsolation',
            type: "POST",
            contentType: false,
            processData: false,
            data: function() {

              //  var inputs = $('#IsolationFO').serializeArray();

 //here i got image path instead of byte array  

             formData.append("Image",$('#other_fileUpload_create').val());


                return formData;
            }(),
...