Permalink
Browse files

add new multipart example yaws_multipart.erl (Praveen Ray)

  • Loading branch information...
1 parent 92681ef commit 4c90d3a7c71aedbd488bd2b4aff9531cdcc47585 @vinoski vinoski committed Sep 28, 2009
Showing with 19 additions and 15 deletions.
  1. +8 −10 www/upload.yaws
  2. +11 −5 www/upload0.yaws
View
@@ -2,11 +2,14 @@
<h2> File upload </h2>
- <p>This page shows how to upload a file to the webserver, nothing of cource
- does actually gets written to disc, but the upload code is
- <a href="code.yaws?file=/upload.yaws"> Here in file upload.yaws </a>
+ <p>This page shows how to upload a file to the webserver, nothing of course
+ actually gets written to disk, but the upload code is
+ <a href="code.yaws?file=/upload.yaws">here in file upload.yaws</a>
</p>
+ <p>A more extensive example is <a href="code.yaws?file=/yaws_multipart.erl">
+ available here</a>.
+ </p>
<erl>
@@ -62,7 +65,7 @@ addFileChunk(_A, [], State) when State#upload.last==true,
file:close(State#upload.fd),
%%file:delete([?DIR,State#upload.filename]),
- Res = {ehtml,
+ Res = {ehtml,
{p,[], "File upload done"}},
{done, Res};
@@ -93,7 +96,7 @@ addFileChunk(A, [{head, {_Name, Opts}}|Res], State ) ->
{done, err()}
end;
-addFileChunk(A, [{body, Data}|Res], State)
+addFileChunk(A, [{body, Data}|Res], State)
when State#upload.filename /= undefined ->
case file:write(State#upload.fd, Data) of
ok ->
@@ -121,8 +124,3 @@ basename(FilePath) ->
</html>
-
-
-
-
-
View
@@ -6,17 +6,23 @@ out(A) ->
{html, [],
{'div',[{id, "entry"}],
[{h1, [], "Upload a file to the webserver"},
- {p, [], "The code that parses the multipart form data resides in"},
- {a, [{href, "code.yaws?file=/upload.yaws"}], "upload.yaws"},
+ {p, [], ["The code that parses the multipart form data resides in ",
+ {a, [{href, "code.yaws?file=/upload.yaws"}], "upload.yaws"},
+ "."]},
{br,[],[]},
{hr,[],[]},
- {form, [{enctype, "multipart/form-data"},
+ {form, [{enctype, "multipart/form-data"},
{method, post},
{action, "/upload.yaws"}
- ],
+ ],
[{input, [{type, submit}, {value, "Upload"}] ,[]},
{input, [{type,file}, {width, "50"}, {name, "foo"}], []}
- ]}]}}},
+ ]},
+ {br,[],[]},
+ {hr,[],[]},
+ {p, [], ["You can also find a more extensive example in ",
+ {a, [{href, "code.yaws?file=/yaws_multipart.erl"}],
+ "yaws_multipart.erl"}, "."]}]}}},
{ssi, "END2",[],[]}].
</erl>

0 comments on commit 4c90d3a

Please sign in to comment.