Quick access

Download & Install

Tutorial & documentation

How to send a file to the server without stopping the client process?

This requires Eliom ≥ 3.1.

Due to security reasons, browsers have limitations on sending files.
But if the file is chosen by the user through an input file element,
there is a way to send it to the server. You can't use the server_function syntax for this, but you can use
Eliom_client.call_caml_service.

Example:

letpic_service=post_coservice'~name:"upload_pic"~post_params:(file"f")(){client{letupload_pic_form()=letfile=D.Raw.input~a:[a_input_type`File]()inletsubmit=D.Raw.input~a:[a_input_type`Submit;a_value"Send"]()inLwt_js_events.(async(fun()->clicks(To_dom.of_inputsubmit)(fun__->Js.Optdef.case((To_dom.of_inputfile)##files)Lwt.return(funfiles->Js.Opt.case(files##item(0))Lwt.return(funfile->Eliom_client.call_caml_service~service:%pic_service()file)))));[pcdata"Upload a picture:";file;submit]}}