on 10-24-2013 10:17 AM
Dear Experts,
I am facing an issue with the file upload UI element.
When I try to upload the file, the file name taken is incorrect. It has 'Drive name' 😕 'fakepath' / 'filename' . 'Extension'
example:
When I click on the above tabel link to download or view the attachment it just displays the junk character in a new window. Tried uploading different file types but the same issue.
Below is the code for on action update.
METHOD onactionupload .
DATA lo_nd_n_upload TYPE REF TO if_wd_context_node.
DATA lo_el_n_upload TYPE REF TO if_wd_context_element.
DATA ls_n_upload TYPE wd_this->element_n_upload.
DATA lo_nd_n_file_download TYPE REF TO if_wd_context_node.
DATA lt_n_file_download TYPE wd_this->elements_n_download.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA ls_file_upload TYPE zhrloan_files.
* navigate from <CONTEXT> to <N_FILE_DOWNLOAD> via lead selection
lo_nd_n_file_download = wd_context->get_child_node( name = wd_this->wdctx_n_download ).
* navigate from <CONTEXT> to <N_UPLOAD> via lead selection
lo_nd_n_upload = wd_context->get_child_node( name = wd_this->wdctx_n_upload ).
* get element via lead selection
lo_el_n_upload = lo_nd_n_upload->get_element( ).
* @TODO handle not set lead selection
IF lo_el_n_upload IS NOT INITIAL.
* get all declared attributes
lo_el_n_upload->get_static_attributes(
IMPORTING
static_attributes = ls_n_upload ).
* ls_n_upload will contain the File name file type and file contents *
DATA lo_nd_it_empdata TYPE REF TO if_wd_context_node.
DATA lo_el_it_empdata TYPE REF TO if_wd_context_element.
DATA ls_it_empdata TYPE wd_this->element_it_empdata.
DATA lv_pernr TYPE wd_this->element_it_empdata-pernr.
DATA lv_loan_type TYPE zloan_type.
* navigate from <CONTEXT> to <IT_EMPDATA> via lead selection
lo_nd_it_empdata = wd_context->get_child_node( name = wd_this->wdctx_it_empdata ).
lo_el_it_empdata = lo_nd_it_empdata->get_element( ).
* get single attribute
lo_el_it_empdata->get_attribute(
EXPORTING
name = `PERNR`
IMPORTING
value = lv_pernr ).
lo_el_context = wd_context->get_element( ).
lo_el_context->get_attribute(
EXPORTING
name = `L_TYPE`
IMPORTING
value = lv_l_type ).
ls_n_upload-file_size = xstrlen( ls_n_upload-file_contents ).
ls_file_upload-l_type = lv_l_type.
ls_file_upload-pernr = lv_pernr.
ls_file_upload-file_name = ls_n_upload-file_name.
ls_file_upload-file_type = ls_n_upload-file_type.
ls_file_upload-file_size = ls_n_upload-file_size.
ls_file_upload-file_contents = ls_n_upload-file_contents.
INSERT ztable_files FROM ls_file_upload.
IF sy-subrc = 0.
SELECT file_name
file_type
file_size
file_contents
FROM ztable_files
INTO TABLE lt_n_file_download
WHERE loan_type = lv_l_type AND pernr = lv_pernr.
lo_nd_n_file_download->bind_table( new_items = lt_n_file_download set_initial_elements = abap_true ).
ENDIF.
ENDIF.
ENDMETHOD.
Please somebody guide me with this issue.
Thanks,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amy,
Thank you very much for your help !
I am able to upload and download images and all other formats like DOC, DOCX, PDF etc., I am saving all the files in the database(In a Z Table).
I am using Download UI Element to download the files that I have uploaded. When I try downloading the files, the file name of the document is prefixed with "C_FAKEPATH_".
For expample: C_FAKEPATH_TESTPDF.PDF. This is happening for all the file types. The uploaded files file name stored in the database also looks like C://FAKEPATH/TESTPDF.PDF.
How do I change the file names when I download the same ?
Warm regards,
Harish
Hi Harish,
One option would be to use the abap split keyword to split the filename string at either the character "_" or the character "/" depending on whether you're parsing the upload or download string. The last row of the result table will be just the filename without any path information. For example,
DATA filename TYPE file_name VALUE 'C://FAKEPATH/TESTPDF.PDF'.
DATA lt_split TYPE TABLE OF file_name.
SPLIT filename AT '/' INTO TABLE lt_split.
The result is table LT_SPLIT contains the following...
Row | TABLE_LINE |
---|---|
1 | C: |
2 | |
3 | FAKEPATH |
4 | TESTPDF.PDF |
Cheers,
Amy
Hi Amy,
Thank you!
I am pretty new to WD ABAP and this is first time i'm facing such kind of issue. How do I parse the file name while uploading or downloading the files? Or can I split the file name and download the uploaded files containing fake path in the link and display only the actual file name without C_FAKEPATH_ ?
Please help me with this. I did some research and found out that some browsers have a security feature that prevents javascript from knowing your file's local full path. Do you think downgrading the browser will work without using any special functions?
Kindly suggest.
Warm regards,
Harish
Hi Harish,
"How do I parse the file name while uploading or downloading the files?"
You can use the split keyword as demonstrated above to manipulate the fileName property of either the FileUpload or FileDownload UI element.
"some browsers have a security feature that prevents javascript from knowing your file's local full path. Do you think downgrading the browser will work without using any special functions?"
Downgrading the browser is not necessary and will not have an effect on the behavior of the fileName of the UI elements. As Sarbjeet mentions above, the behavior of the FileUpload and FileDownload UI elements are features of Web Dynpro and are not controlled by the web browser.
Maybe you can give more detail about your scenario and what you are trying to do. Also, in your system take a look at demo component WDR_TEST_EVENTS and its views FILEUPLOAD and FILEDOWNLOAD. The demo component gives an example of these UI elements in action that may be helpful to you.
In case it is helpful to you, see also the information on File Export and examples of its functionality in view BUTTON of component WDR_TEST_EVENTS.
Cheers,
Amy
Hi Harish,
I believe there is a problem in uploading the file. Debug and check what is the file extension you are getting. Read the structure which has attributes for file name, file type etc get the attribute file name and pass it to function module
'DSVAS_DOC_FILENAME_SPLIT' it will give you the apt file extension use this extension to store the document and if u click on file download you will not face any problem.
Becos i am faced a similar problem like this and found out this function module and my problem got solved.
Thanks & Regards
Arun.K.P
While uploading any type of document
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.