ng2-file-upload怎么安装
发布网友
发布时间:2022-05-26 08:41
我来回答
共2个回答
热心网友
时间:2023-10-09 19:24
<input id="Button1" runat="server" onserverclick="Button1_ServerClick" type="button"
value="传" />
//Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class up : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_ServerClick(object sender, EventArgs e)
{
//取字符串:C:\Documents and Settings\Administrator\Desktop\picture\213.jpg
string fileName = this.FileUpload1.PostedFile.FileName;
//取始\度:fileName.LastIndexOf("\\")
int length = fileName.Length - fileName.LastIndexOf("\\") - 1;
//截取fileName.LastIndexOf("\\") + 1位置length位置字符串
fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1, length);
//取字符串:C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\WebSite1\upload2\
string path = Server.MapPath("upload2\\");
//判断没path文件没则创建新
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
//取文件缀名:.jpg
string s1 = System.IO.Path.GetExtension(fileName);
//取Web.Config 配置值
string s2=System.Configuration.ConfigurationManager.AppSettings["conn"];
//取传文件单位bytes
int filesize = (FileUpload1.PostedFile.ContentLength) / 1024;
if (s1 == ".jpg" || s1 == ".gif")
{
//文件<设定则传文件:C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\WebSite1\upload2\213.jpg
if (filesize < Convert.ToInt32(s2))
{
FileUpload1.PostedFile.SaveAs(path + fileName);
}
else
{
Response.Write("");
}
}
else
{
Response.Write("");
}
}
}
热心网友
时间:2023-10-09 19:24
$npm install ng2-file-upload --save