Skip to Content
0
Former Member
Dec 10, 2008 at 04:30 AM

How to Upload image to MIME object using fileUpload?

717 Views

Hi Experts,

I want to upload image from my PC to MIME in image folder and get this image on my BSP view as well after the trip back from the Controller class (after the click 'Upload').

I have the following code on my BSP view.

<htmlb:fileUpload id          = "uploadID"
                  onUpload    = "UploadFile"
                  upload_text = "Upload File" />

In DO_HANDLE_EVENT of the view controller class I have the following code

 fileupload ?= cl_htmlb_manager=>get_data( request = request
                                                id      = 'mvw_uploadID'
                                                name    = 'fileUpload'     ).

      lv_filename       = fileupload->file_name.
      lv_file_mime_type = fileupload->file_content_type.
      lv_file_length    = fileupload->file_length.
      lv_file_content   = fileupload->file_content.  

I am able to get all the above details and lv_file_content as xstring which contains the content.

what do I need to do now to transfer this image to MIMEs image folder?

I have tried something like this which did not work.

DATA: o_mr_api TYPE REF TO if_mr_api.
 IF o_mr_api IS INITIAL.
        o_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).
 ENDIF.

o_mr_api->put(
  EXPORTING
    i_url                     = '/SAP/BC/BSP/SAP/(ZBSP Application)/images'
    i_content                 = lv_file_content
  EXCEPTIONS
    parameter_missing            = 1
    error_occured                    = 2
    cancelled                          = 3
    permission_failure              = 4
    data_inconsistency            = 5
    new_loio_already_exists     = 6
    is_folder                            = 7
    OTHERS                           = 8 ). 

I get sy-subrc = 7, I have tried man y different paths and methods.

I am not able to get the desired result.

I would appreciate your help.

Thanks & Regards,

Abhinav