Languages

Menu
Sites
Language
How to upload images in a WebView?

Hello! I want to create a simple native app, based on webview tutorial. I get this code and tried it in an emulator, but when I want to upload file or photo, for example, on Facebook - nothing happening.

So, I got a simple question - how to upload images and files from the gallery on Tizen webview?

This is a source code (I didn't change anything):

https://developer.tizen.org/community/tip-tech/webview-native-application

Thank you so much!

Responses

3 Replies
Yasin Ali

Hi,

You may try selecting image and then passing it to webview. Below is a code to pick image and as result return path

//    PRIVILEGE needed to be set in tizen-manifest.xml:
//    http://tizen.org/privilege/appmanager.launch

#include <dlog.h> // for logging purposes
#include <app_control.h>


void
pick_image_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) {
    char* path;

 if(result == APP_CONTROL_RESULT_SUCCEEDED) {
  if(app_control_get_extra_data(reply, "path", &path) == APP_CONTROL_ERROR_NONE)
   LOGI("Selected image path: %s", path);
 }
}

void
pick_image() {
 app_control_h app_control = NULL;
 app_control_create(&app_control);
 app_control_set_operation(app_control,  APP_CONTROL_OPERATION_PICK);
 app_control_set_mime(app_control,  "image/*");
 if(app_control_send_launch_request(app_control, pick_image_reply_cb, NULL) == APP_CONTROL_ERROR_NONE)
    LOGI("Gallery launched!");
 app_control_destroy(app_control);
}

Hope it will help.

dev madrad

Hello,

Yasin Ali, this is not all what authow asks about. Your code will be helpful when you will catch upload request.

Roman, Probably you need to register callback for "contextmenu,selected" signal using evas_object_smart_callback_add

I am not sure about signal so please check it on your own and let us know the result.

Yasin Ali

Hope to hear from Roman Savchyn soon.