2
votes

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

1
HTTP Status Code 500 simply means there's something wrong in your PHP code.Amit Merchant
yes but the same code works fine on my localhost, the file is properly getting uploaded. It shows this error for remote serverHitesh
Well, with information this little, I can't help much. Provide more info if you can.Amit Merchant
i have added the code for reference @AmitMerchantHitesh
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?Nordseebaer

1 Answers

0
votes

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.