Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(gallery).
- -export([out/1]).
- -include("/usr/lib/yaws/include/yaws_api.hrl").
- out(A=#arg{req=#http_request{method='GET'}}) ->
- case A#arg.appmoddata of
- undefined ->
- {ehtml, [{h1, [], "Upload form"},
- {form, [{method, "post"},
- {enctype, "multipart/form-data"}],
- [{input, [{type, "file"},
- {name, "file"}]},
- {input, [{type, "submit"},
- {value, "Upload"}]}]}
- ]};
- Other ->
- {ehtml, [{h1, [], "Appmod path"},
- {p, [], ["Path: ", Other]}
- ]}
- end;
- out(A=#arg{req=#http_request{method='POST'}}) ->
- MultipartOpts = [no_temp_file],
- case yaws_multipart:read_multipart_form(A, MultipartOpts) of
- {done, Params} ->
- [{filename, Filename}, {value, Contents}] = dict:find("file", Params),
- {ehtml, [{h1, [], "File received"},
- {p, [], ["Received ", Filename]}
- ]};
- {error, Reason} ->
- {ehtml, [{h1, [], "Error"},
- {p, [], ["Reason: ", Reason]}
- ]};
- Other ->
- Other
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement