Languages

Menu
Sites
Language
except gallery app, is there other way to upload image?

now, i'm developing an app, i need to select an image on the device, and then upload it to the server.

i notice the previous article "How to launch gallery app and retrieve which file is selected?".

it mentioned that we can use gallery app to finish this work.

is there other way to do it?

for example, use input which the type is 'file', and use html5 file object.

it's my code:

html:

<input id="imgFile" type="file"  />

jquery:

$("#imgFile").bind('change', function() {

    var fileList = this.files;
    var reader = new FileReader();
 
    for ( var i = 0, numFiles = fileList.length; i < numFiles; i++) {
        var file = fileList[i];
 
        reader.readAsDataURL(file);
        reader.onload=function(event){
            try {
                var data = {
                   'name' : file.name,
                   'type' : file.type,
                   'bits' : new Base64(event.target.result.replace('data:image/jpeg;base64,','').replace('data:video/x-ms-wmv;base64,','')),
                   'overwrite' : false
               };
 
               var connection = new UploadFile(username, password, rpcUrl, data);
               connection.startConn();
            } catch (error_obj) {
               alert("showErrorDialog: " + error_obj.name + "--" + error_obj.message);
            }
        }
    }
});
 
it works fine on 'tizen web simulator applaction', but it can't work on tizen device.
 
can anyone helps me?
Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

1 Replies
Lakshmi Grandhi
There is already bug in JIRA regarding file upload using input type as file. https://bugs.tizen.org/jira/browse/TWEB-111