我正在尝试创建一个允许用户创建文件上传表单的剃刀功能。
该函数的参数是:
- ContentPath - 服务器上将存储文件的路径
- FilePrefix - 可选前缀
- FileSuffix - 可选后缀
我想知道这样的事情是否已经完成?如果不是,我似乎可以理解表单发布到哪里?实际上传的代码在哪里?
这就是我到目前为止所拥有的。
@inherits RazorFunction
@functions {
public override string FunctionDescription
{
get { return "This is a file upload component."; }
}
[FunctionParameter(Label="Content Path", Help="Relative path of the folder that the files sholud be sotred in.", DefaultValue = "/Uploads")]
public string ContentPath { get; set; }
[FunctionParameter(Label = "File Prefix ", Help = "A prefix to append to the uploaded file.", DefaultValue = "")]
public string FilePrefix { get; set; }
[FunctionParameter(Label = "File Suffix ", Help = "A suffix to append to the uploaded file (befire the extention).", DefaultValue = "")]
public string FileSuffix { get; set; }
}
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://www.composite.net/ns/function/1.0">
<head>
@* script, css etc. you add in this head section end up in the head on the rendered page *@
</head>
<body>
<form method="post" enctype="multipart/form-data" action="/Controller?">
<input type="file" name="files[]" id="files[]" multiple="multiple" />
<input type="submit" value="Upload files"/>
</form>
</body>
</html>