Cordoba / Phonegap FileTransfer.upload () error code = 1 (FILE_NOT_FOUND_ERR)

Which is really confusing, when I fix the image using the phone’s camera, I use FileTransfer.moveTo and it sends the image to the specified folder on the SD card as desired. I also save a list of image objects in localStorage , which looks something like this:

 [ Object ean: "42208556" image: "file:///storage/sdcard0/PhotoscanPhotos/d51b5b77-aab1-9947-096d-b0a92dfb87eafoto.jpg" timestamp: 1396441761000 __proto__: Object etc etc 

As part of my application, I use the same [i] .image image as the src attribute to dynamically add images to the list, and it works great. However, using the same parameter for FileTransfer.upload gives me the above error.

My function is a close copy of the API documents (Cordova 3.1). The code is as follows:

 function uploadImagesAsJpegs(imageObject) { var options = new FileUploadOptions(); options.fileKey = "file"; options.fileName=imageObject.image.substr(imageObject.image.lastIndexOf('/')+1); //alert(options.fileName);//debugging ............we're happy with this options.mimeType="image/jpeg"; options.chunkedMode = true; var serverUrl = http://172.17.7.112/mylocalserver; var params = {}; params.value1 = ean; params.value2 = imageObject.timestamp; options.params = params; var fileTransfer = new FileTransfer(); //alert(encodeURI(serverURL));//debugging ............we're happy with this //alert("image to upload is: " + imageObject.image);//debugging............we're happy with this fileTransfer.upload(imageObject.image, encodeURI(serverURL), onUploadSuccess, onUploadFail, options); } 
+6
source share
3 answers

The serverside script was wrong ... naturally, I should have figured this out given the obvious FileTransferError.FILE_NOT_FOUND_ERR error FileTransferError.FILE_NOT_FOUND_ERR . We apologize for spending all the time and thank you for your efforts.

0
source

I believe setting options.chunkedMode = false; solves most of the problems during file upload, maybe try.

+7
source

I would try: 1. use exclusive mode to load (true at the end)

fileTransfer.upload (imageObject.image, encodeURI (serverURL), onUploadSuccess, onUploadFail, Options, true);

  • Try to transfer the data first to the local device store, and not to work with the storage of the SD card. Perhaps this is a permission case, and you can simply download from local storage.

  • Make sure that the image is not pending in another image as the image source, and that you have full access to the data. Perhaps reading and writing should be exclusive.

+3
source

All Articles