The goal
I want to upload two files, and put the IP address of the uploader in the filename
The solution
open Lwt open XHTML.M open Eliom_services open Eliom_parameters open Eliom_sessions open Eliom_predefmod.Xhtml let upload = Eliom_services.new_service ~path:[""] ~get_params:unit ();; let upload2 = register_new_post_service ~fallback:upload ~post_params:((file "file_horizontal")**(file "file_vertical")) (fun sp () (f_h,f_v) -> let to_display = let name_h = ("/tmp/t_f_h-"^(Unix.string_of_inet_addr (Eliom_sessions.get_remote_inet_addr sp))) and name_v = ("/tmp/t_f_v-"^(Unix.string_of_inet_addr (Eliom_sessions.get_remote_inet_addr sp))) in (try Unix.unlink name_h with _ -> ()); Unix.link (Eliom_sessions.get_tmp_filename f_h) name_h; (try Unix.unlink name_v with _ -> ()); Unix.link (Eliom_sessions.get_tmp_filename f_v) name_v; (name_h^" et aussi "^name_v); in Lwt.return (html (head (title (pcdata "Upload")) []) (body [h1 [pcdata to_display]])));; let uploadform = register upload (fun sp () () -> let f = (post_form upload2 sp (fun (file_horizontal, file_vertical) -> [p [file_input ~name:file_horizontal (); br (); file_input ~name:file_vertical (); br (); string_input ~input_type:`Submit ~value:"Send" ()]] ) ()) in Lwt.return (html (head (title (pcdata "form")) []) (body [f])));;