0

I am uploading an image using chrome extension. My process flow as

Read image ->

file reader(readAsText)

Extension ->

formData.append('uploadFile', new Blob([file], {
    type : data.fileType
}));

$.ajax({
    type : "POST",
    url : URI,
    data : formData,
    contentType : false,
    processData : false,
    cache : false,
    async : true,
    success : function (result) {

    }
});`

When I retrieve image using tag I am getting an corrupted image. When I check with server for files using direct fileupload using form submit and extension have same data but encoding type was different.

Direct upload file saved as ANSI format and extension saved as UTF-8.

  • You may want to check on how you convert the image to format (base64) that is why your image is corrupted. Here is a [github](https://gist.github.com/kosso/1958464) that upload images to imgurl, it is not using formData but you might want to check how the developer gets the image and get the image blob and encode it properly. Lastly here is a related [post](http://stackoverflow.com/a/21138567/5995040) that a formData to upload an image file. Hope this helps. – Mr.Rebot Dec 04 '16 at 15:37
  • When I use direct upload the file was stored with charset as ANSI. If I use extension it was stored as UTF-8. It may be the reason for this issue? – Sharavanakumaar Murugesan Dec 06 '16 at 11:40

0 Answers0