FineUI 官方论坛

标题: FineUI开源版,FileUpload能同时上传多张照片吗? [打印本页]

作者: ytcola    时间: 2017-2-22 14:03
标题: FineUI开源版,FileUpload能同时上传多张照片吗?
本帖最后由 ytcola 于 2017-2-22 14:16 编辑

现在在做一个项目,需要同时上传多张照片,FileUpload控件支持同时上传多张照片吗?


作者: zy32002    时间: 2017-2-22 14:43
可以用第三方的jq插件,比如说uploadify
作者: ytcola    时间: 2017-2-22 20:02
本帖最后由 ytcola 于 2017-2-22 20:04 编辑

测试了一个asp.net版本的多文件上传,好用,把代码放到fineui中即可网页代码:
<div>
        <aspabel ID="Label1" runat="server" Height="269px" Text="Label" Width="360px"></aspabel>
        <asp:FileUpload ID="FileUpload1" runat="server" multiple="multiple"/>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="FileUpload1"
        ErrorMessage="必须是 jpg或者gif文件" ValidationExpression="^(([a-zA-Z]|(\\{2}\W+)\$?)(\\(\W[\W].*))+(.jpg|.Jpg|.gif|.Gif)$"></asp:RegularExpressionValidator>此处可用可不用--%>
    </div>


c#代码:
protected void Button1_Click(object sender, EventArgs e)
        {
            string filepath = Server.MapPath("upload") + "\\";
            HttpFileCollection uploadFiles = Request.Files;
            for (int i = 0; i < uploadFiles.Count; i++)
            {
                HttpPostedFile postedFile = uploadFiles;
                try
                {
                    if (postedFile.ContentLength > 0)
                    {
                        Label1.Text += "文件 #" + (i + 1) + ":" + System.IO.Path.GetFileName(postedFile.FileName) + "<br/>";
                        postedFile.SaveAs(filepath + System.IO.Path.GetFileName(postedFile.FileName));
                    }
                }
                catch (Exception Ex)
                {
                    Label1.Text += "发生错误: " + Ex.Message;
                }
            }
        }






欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/) Powered by Discuz! X3.4