Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the following code

    onDeviceReady: function () {
    navigator.camera.getPicture(
                app.uploadPhoto,
                function (message) { alert('get picture failed'); },
                {
                    quality: 50,
                    destinationType: navigator.camera.DestinationType.FILE_URI,
                    sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
                }
            );
},
uploadPhoto: function(imageURI) {
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";

var params = {};
params.value1 = "test";
params.value2 = "param";

options.params = params;

var ft = new FileTransfer();
ft.upload(imageURI, encodeURI("http://192.168.0.101/upload/index.php"), app.win, app.fail, options);
},

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

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

It's working, however when I send to my php I do not know how to save, my code this way:

<?php
move_uploaded_file($_FILES["file"]["tmp_name"], 'C:xampphtdocsuploadimages');
    ?>

I would like to save in 'C:xampphtdocsuploadimages', as should be my php?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
211 views
Welcome To Ask or Share your Answers For Others

1 Answer

Could run as follows, the js was so

ft.upload(fileURI, encodeURI("http://192.168.0.102/upload/index.php"), app.win, app.fail, options);

The index.php Receives and sends it to the images folder inside of That Is upload.

 <?php
    $new_image_name = strtolower($_FILES['file']['name']);
    move_uploaded_file($_FILES["file"]["tmp_name"], "images/".$new_image_name);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...