0

Rather than using a Handler(.ashx), is it possible to use a web service(.asmx) to upload?

Any suggestions on how to use a jQuery upload to get the input stream?

VB.NET code or examples would be appreciated.

Chad Levy
  • 10,032
  • 7
  • 41
  • 69
Amit Pore
  • 127
  • 3
  • 13

2 Answers2

1

Yes it is possible , you can pass the File to the service(.asmx) , and get Json back by specifing the response type. better soultion if you want a simple uploader with drag and drop functionality would be Ajax uploader - valums

_uploader = new qq.FileUploader({
                element: document.getElementById(_Uploaddiv),
                onComplete: function (id, fileName, responseJSON) {  },
                action: '/Uploader.asmx/functionName',
                params: {
                    startRowIndex:_startRowIndex,
                    pageSize:_pageSize
                }

    xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");

set the XMLHttpRequest() headers to Accept json

VB code

<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _

Simple , light, accepts my CSV and gets me the result. that's what i wanted

Amit Pore
  • 127
  • 3
  • 13
0

Jquery has a Forms plugin which can be used for this purpose. The good thing about it, it supports file upload using AJAX as well.You can locate it here http://plugins.jquery.com/project/form. We are using it with MVC 3.

Prasad Pimparkar

Prasad
  • 1,347
  • 2
  • 9
  • 7