on 02-13-2013 5:32 PM
Is there a way to limit the Browse on a file upload to only go after certain types, in my case, PDFs ?
Thanks for all the followon info - I'm going to close this question - Just to clarify, the question was can we somehow (proactively) only allow the user to select certain filetypes - and I think the answer is "No".
Thanks all...
...Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In FILEUPLOADUI Upload Event
------------------------------------------
lv_file_upload ?= wd_this->mr_view->get_element( 'FILEUPLOADUI' ).
* get the content of the filename property
lv_filefullname = lv_file_upload->get_file_name( ).
* call function 'SO_SPLIT_FILE_AND_PATH'
* exporting
* full_name = lv_filefullname
* importing
* stripped_name = l_filename_ext.
call function 'Z_HR_ATTACH_SPLIT_PATH'
exporting
l_filenam_w_path = lv_filefullname
importing
* E_PATH = E_PATH
e_filename = l_filename_ext .
* E_SERVER = E_SERVER .
split l_filename_ext at '.' into: l_filename l_ext_name .
call function 'Z_HR_CHK_ATTACH_EXT'
exporting
i_ext = l_ext_name
importing
e_ok_ext = l_ok_ext .
if l_ok_ext = space.
lv_msg-msgty = 'E'.
lv_msg-msgid = 'ZHR'.
lv_msg-msgno = '727'.
lv_msg-msgv1 = 'File extension ' .
lv_msg-msgv2 = l_ext_name .
lv_msg-msgv3 = ' not allow' .
lv_msg-msgv4 = space .
* report message
elem_context->set_attribute_null('DATA' ).
call method wd_comp_controller->mo_message_manager->report_attribute_t100_message
exporting
msg = lv_msg
element = elem_context
attribute_name = 'DATA'.
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yes, It is possible. Create an attribute mime_type in context and bind the mime_type property of the file upload UI to that attribute. After browsing and selecting the file path and on click of Upload button, Read the mime type and display an error message if it is not the required type. for pdf mime type will be 'application\pdf' i guess.
Or,
bind the file name property of file upload UI to an attribute( file_name), read the file name in the onAction of upload button and read the file extension ( last occurrence of . dot) . and display error if it is not required type.
Hope this helps u.,
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think the poster wanted the file upload control to limit the file type to *.pdf for example, so that only those files are shown for the user to choose from. I'm not aware that it's possible. The file upload control will remember the previous setting but to default it, some fancy scripting would have to take place to which there probably isn't any interface in WDA. That said there are even differencies in how different browsers work.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.