I have a problem: I need to read file from post param in ChicagoBoss. I'm trying:
upload_file('POST', []) ->
File = Req:post_param("file"),
{ok,Data} = file:read_file(File),
And have an error:
{{badmatch,{error,enoent}}
When I'm trying to check the file like:
case filelib:is_file(File) of
true -> {output, "ok"};
false -> {output, "error"}
end.
I have error
output.
I'm trying to upload file with Postman. Where is the problem?
enoent
is the posix error code for "directory not found."http://www.erlang.org/doc/man/file.html#del_dir-1
Also, your code allows people to read arbitrary files from disk. That will eventually lead to a server attack.