0

I've seen pretty good sample code using HTML5 but we have to develop a solution that works for most browsers. I found solutions that use iFrame and a nice AJAX plug in such as (https://github.com/blueimp/jQuery-File-Upload) but all samples are for PHP or use the HTML File tag ().

I need to create a WCF service that accepts a Stream and a simple jQuery AJAX call where I will pass the file path such as C:\TEST\FILE001.ZIP (instead of displaying the File TextBox with the BROWSE... button for the user to pick out the file).

Something like:

$.ajax(
{
async: false,
cache: false,
data: 
{
    "fileID" : "1234",
    "fileName" : "C:\TEST\FILE001.ZIP"
},
complete: function (jqXHR, textStatus)
{
},
error: function (jqXHR, textStatus, errorThrown)
{  
    alert("errorThrown: " + JSON.stringify(jqXHR) + '  ' + textStatus + '  ' + errorThrown )     
},
success: function (data, textStatus, jqXHR)
{       
},
type: "POST",
url: "svc/Test.svc/UploadFile"
});

How do I do that? The closest forum thread I found was this: Working example of AJAX file upload to WCF service but that didn't seem to be a complete answer as it did not work for me.

I also found this one which seems to be exactly what I need but no answer either: Upload a complex object to a WCF REST Service from JQuery

Thank you

Community
  • 1
  • 1
Max
  • 1,289
  • 3
  • 26
  • 50
  • Please refer the following SO Post: http://stackoverflow.com/questions/2320069/jquery-ajax-file-upload , http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery – Rajesh May 21 '13 at 16:32
  • thanks that clarifies a lot! – Max May 22 '13 at 14:42

1 Answers1

1

You cannot just pass file location. It is because server side does not have access to client computer

The example you are looking for is here: https://github.com/maxpavlov/jQuery-File-Upload.MVC3

Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116