2

I am trying to upload a file using my cordova app. The file was uploaded successfully when i was testing with localhost url. Now when i am trying with my remote server, it gives me the following error. It looks like its not even hitting the upload-url

 FileTransferError {code: 1, source: "file:///storage/emulated/0/rec_13_13_11.wav", target: "https:///mobile_api/upload-hla-call-recording", http_status: 500, body: null, …} body:null code:1 exception:"https://route/to/upload/file" http_status:500 source:"file:///storage/emulated/0/rec_13_13_11.wav" target:"https://route/to/upload/file" 

Here is the code for uploading file

 fileSystem.root.getDirectory(dirName, { create: false }, function (dataDir) { fileURI = dataDir.toURL(); fileURI = fileURI + fileName; var options = new FileUploadOptions(); options.fileKey = "fileKey"; options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1); options.mimeType = "audio/mp3"; options.chunkedMode = false; var ft = new FileTransfer(); ft.upload(fileURI, server-url, win, fail, options, true); }, dirFail); 

I am using cordova-plugin-file-transfer to upload the file

6
  • HTTP Status Code 500 simply means there's something wrong in your PHP code. Commented Feb 9, 2018 at 7:55
  • yes but the same code works fine on my localhost, the file is properly getting uploaded. It shows this error for remote server Commented Feb 9, 2018 at 7:57
  • Well, with information this little, I can't help much. Provide more info if you can. Commented Feb 9, 2018 at 8:00
  • i have added the code for reference @AmitMerchant Commented Feb 9, 2018 at 8:21
  • And the path <domain>/route/to/upload/file really exists on your Server? I mean in document root of your web app? Did you check write permissions of your webserver? Commented Feb 10, 2018 at 4:03

1 Answer 1

0

The issue was regarding the guzzlehttp. It was looking for https connection while my localhost was working on http. Either force the curl for http or provide a certificate with your http request.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.