1

I am kinda stuck right now. My VB script doesn't read the image blob, or does not get the file. I hope you can all help. Here is my code.

The image here is already in base64 and already being converted to blob and added to a form

var blob = dataURItoBlob(final_image.src);
var formData = new FormData();
formData.append("objFile", blob, "image.jpeg");

$.ajax({
    url: 'UploadImage/ ImageFunction',
    data: { IDName: sessionStorage.IDName, CanvasImage: formData },
    cache: false,
    processData: false,
    contentType: false,
    type: 'POST'
});

As you can see it here, it now being sent to the vb script. THe problem is that it doesnt read the blob file and doesnt save.

Function ImageFunction()
    Dim directory As String
    Dim objFile As HttpPostedFileBase = Request.Files("objFile")
    Dim counter As Integer = Request.Files.Count

    If Not System.IO.Directory.Exists("temp\Pictures") Then
        IO.Directory.CreateDirectory("temp\Pictures")
    End If

    directory = "temp\Pictures\"

    If Not System.IO.Directory.Exists(directory & Common.WebRequest.Data("IDName")) Then
        IO.Directory.CreateDirectory(directory & Common.WebRequest.Data("IDName"))
    End If

    If (Not objFile Is Nothing) Then
        objFile.SaveAs(directory & Common.WebRequest.Data("IDName") & "\" & Common.WebRequest.Data("IDName") & ".jpg")
    End If
End Function

Can someone lighten me if where have I gone wrong?

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

Take a look to this question:

Using jQuery's ajax method to retrieve images as a blob

If it is necesary to use ajax maybe you need to use native XMLHttprequest.

I hope helps!

Community
  • 1
  • 1
jcarrera
  • 1,007
  • 1
  • 16
  • 23
  • nope.... I cant use the the link you give since I will be sending two data, first is the blob and the second one is the IDName.. besides both of then have to be sent –  Jul 20 '15 at 09:52
  • So you could make a form with a file type input and enctype=multipart/form-data for sending both the file and the IDName. – jcarrera Jul 20 '15 at 10:00
  • @jcarrerra you lost me there.... –  Jul 20 '15 at 10:54