Vito Di Gravina
Vito Di Gravina

Reputation: 11

When I wanted to load an image into my cordova ios app, it tells me that the image is not found

In my app there is a function where it allows me to upload a photo, when I click to upload it and select the photo after it does not upload the photo to the server.

And me showing this error in xcode:

    4 Midica 0x000000010471b07c __25-[CDVCamera takePicture:]_block_invoke + 1084
    5 libdispatch.dylib 0x00000001050d06d4 _dispatch_call_block_and_release + 32
    6 libdispatch.dylib 0x00000001050d23b4 _dispatch_client_callout + 20
    7 libdispatch.dylib 0x00000001050d4f2c _dispatch_queue_override_invoke + 1052
    8 libdispatch.dylib 0x00000001050e6500 _dispatch_root_queue_drain + 408
    9 libdispatch.dylib 0x00000001050e6f0c _dispatch_worker_thread2 + 196
    10 libsystem_pthread.dylib 0x00000001f0ea60b8 _pthread_wqthread + 228
    11 libsystem_pthread.dylib 0x00000001f0ea5e94 start_wqthread + 8
    2021-12-01 10:41:00.874693+0100 Midica[16299:4370500] Error opening file http://localhost:52474/local-filesystem/var/mobile/Containers/Data/Application/333C35EE-D28F-48DA-A04C-00AB1A384A89/tmp/cdv_photo_014.jpg: Error Domain=NSCocoaErrorDomain Code=260 "The file “cdv_photo_014.jpg” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/local-filesystem/var/mobile/Containers/Data/Application/333C35EE-D28F-48DA-A04C-00AB1A384A89/tmp/cdv_photo_014.jpg, NSUnderlyingError=0x2826aadf0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
    2021-12-01 10:41:00.874802+0100 Midica[16299:4370500] FileTransferError {
    code = 1;
    source = "http://localhost:52474/local-filesystem/var/mobile/Containers/Data/Application/333C35EE-D28F-48DA-A04C-00AB1A384A89/tmp/cdv_photo_014.jpg";
    target = "http://www.seciconsulting.com/mercati_rionali/Mercati%2520Pdc/upload_foto.php";
    }

And this is my code:

    $(document).on('tap', '#scatta_foto1', function(event) {
    event.preventDefault();
    
    if (app.isJQMGhostClick(event)) {
    return;
    }
    
    navigator.camera.getPicture(function(imageData) {
    
    var options = new FileUploadOptions();
    options.fileKey = "file";
    options.fileName = imageData.substr(imageData.lastIndexOf('/') + 1);
    options.mimeType = "image/jpg";
    options.chunkedMode = true;
    
    app.setV('immagine1', options.fileName);
    app.setV('img1_salv', options.fileName);
    
    var ft = new FileTransfer();
    
    ft.upload(imageData, encodeURI(app.getV('root') + 'upload_foto.php'), function win(r) {
    $('#immagine1').attr('src', encodeURI(app.getV('root_img') + options.fileName));
    $('.foto1').show();
    }, function fail(error) {
    alert('Image: ' + imageData + 'Failed because: ' + error.code + ' source: ' + error.source+ ' target: ' + error.target + ' status: ' + error.status + ' body: ' + error.body + ' exception: ' + error.exception);
    }, options, true);
    }, function(message) {
    
    }, {
    quality : 50,
    encodingType : Camera.EncodingType.JPG,
    destinationType : Camera.DestinationType.FILE_URI,
    sourceType : navigator.camera.PictureSourceType.PHOTOLIBRARY
    });
    
    event.stopImmediatePropagation();
    });

Upvotes: 1

Views: 173

Answers (0)

Related Questions