ioseve
ioseve

Reputation: 145

File Transfer Error with phonegap

In my phone gap application i want to use filetransfer option to transfer the image in server.I have used the following code

function uploadPhoto(imageURI) 
         {
          var options = new FileUploadOptions();
          options.fileKey="file";
          options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
          options.mimeType="image/jpeg";
          var params = {};
          params.value1 = "Admin";
          params.value2 = "Admin123";
          options.params = params;
          var ft = new FileTransfer();
          ft.upload(imageURI, encodeURI("ftp.bimgupl.com/itemimage/"), win, fail, options);
        }

        function win(r)
        {
            console.log("Code = " + r.responseCode);
            console.log("Response = " + r.response);
            console.log("Sent = " + r.bytesSent);
        }

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

In the above code returns the result as

  An error has occured:Code=3

The link details as follows

 FTP username: Admin
 FTP Password: Admin123
 FTP server: ftp.bimgupl.com
 FTP & explicit FTPS port: 21

Whats wrong with my code?please help me to solve the issue.

Upvotes: 1

Views: 758

Answers (1)

Vicky Gonsalves
Vicky Gonsalves

Reputation: 11717

u cannot upload file directly to ftp server..you ll need a php handler to move uploaded file to desired directory..Read this file upload php

Upvotes: 1

Related Questions