Code: Alles auswählen.
<h2> Form with Method POST and enctype "multipart/form-data"</h2>
<form method="POST" enctype="multipart/form-data">
<table border=1 width="100%">
Code: Alles auswählen.
* file upload and echo
data: entity type ref to if_http_entity,
file type xstring,
content_type type string,
content_length type string,
num_multiparts type i,
i type i value 1,
doEcho type string.
* find multipart containing file
num_multiparts = request->num_multiparts( ).
while i <= num_multiparts.
entity = request->get_multipart( i ).
value = entity->get_header_field( '~content_filename' ).
if not value is initial.
* found a file!
navigation->set_parameter( name = 'content_filename'
value = value ).
content_type = entity->get_header_field( 'Content-Type' ).
navigation->set_parameter( name = 'content_type'
value = content_type ).
* get file content
file = entity->get_data( ).
* get file size
content_length = xstrlen( file ).
navigation->set_parameter( name = 'content_length'
value = content_length ).
* echo/download the same file again?
doEcho = request->get_form_field( 'doEcho' ).
if doEcho is not initial.
* set response data to be the file content
runtime->server->response->set_data( file ).
* set the mime-type and file size in the response
runtime->server->response->set_header_field(
name = 'Content-Type'
value = content_type ).
runtime->server->response->set_header_field(
name = 'Content-Length'
value = content_length ).
runtime->server->response->delete_header_field(
name = 'Cache-Control' ).
runtime->server->response->delete_header_field(
name = 'Expires' ).
endif.
exit.
endif.
i = i + 1.
endwhile.
if doEcho is not initial.
* signal to the BSP runtime that the response data is
* complete and no onLayout method should be called to
* create the response
navigation->response_complete( ).
else.
navigation->goto_page( 'transition_parameter_upload.htm' ).
endif.