Cordova upload filetransfer returned html and no file uploaded

I seem to run into a wall trying to upload photos to the server using Cordova (3.5) and Eclipse. I checked my code several times and the person who wrote the aspx service checked things on their side. I am using the filetransfer plugin and the downloads are working fine, so I assume everything is fine. Here is the download code:

function uploadImage(fileURL)
    var win = function (r) {
        alert("Code = " + r.responseCode);
        alert("Response = " + r.response);
        alert("Sent = " + r.bytesSent);

    var fail = function (error) {
        alert("An error has occurred: Code = " + error.code);
        alert("upload error source " + error.source);
        alert("upload error target " +;


    var options = new FileUploadOptions();
    options.fileKey = "myfile";
    options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
    options.mimeType = "image/jpeg";

    alert(fileURL.substr(fileURL.lastIndexOf('/') + 1));
    var params = {};
    params.value1 = "test";
    params.value2 = "param";

    options.params = params;

    var ft = new FileTransfer();
    ft.upload(fileURL, encodeURI(""), win, fail, options);


I am warning file file size in url file, path is ok.

The server side code looks like this:

        public string saveFile()
            string msg = "";
                HttpPostedFile file = HttpContext.Current.Request.Files["myfile"];
                string saveFile = file.FileName;
                file.SaveAs(Server.MapPath("/LocationImages/" + saveFile));

                msg = "File uploaded";

            catch (Exception ex)
                msg = "Could not upload file: " + ex.Message;

            return msg;


When ever this method is executed, I get a response with html, which seems to be an error page with a back button. Code 200 is returned from cordova and bytes sends 98547. I don't understand how the success is triggered, nothing is explicitly sent.

I added an error to the server path:

ft.upload (fileURL, encodeURI (" aveFilzz "), win, fail, options);

And the results are the same: success code 200, same html response and bytes send

I have verified that res / xml / config.xml has

Maybe someone with a better understanding of cordova or web services can shed some light on this?

Any ideas would be greatly appreciated!


source to share

All Articles