kindeditor如何在.NET中应用,主要是上传图片时出错
发布网友
发布时间:2022-04-21 06:32
我来回答
共2个回答
热心网友
时间:2023-11-06 15:44
protected void Button1_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
Boolean fileOK = false;
String path = Server.MapPath("~/UploadedImages/");
if (FileUpload1.HasFile)
{
String fileExtension =
System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
String[] allowedExtensions =
{ ".gif", ".png", ".jpeg", ".jpg" };
for (int i = 0; i < allowedExtensions.Length; i++)
{
if (fileExtension == allowedExtensions[i])
{
fileOK = true;
}
}
}
if (fileOK)
{
try
{
FileUpload1.PostedFile.SaveAs(path
+ FileUpload1.FileName);
Label1.Text = "File uploaded!";
}
catch (Exception ex)
{
Label1.Text = "File could not be uploaded.";
}
}
else
{
Label1.Text = "Cannot accept files of this type.";
}
}
}
你好好看看这个例子
是MSDN里面的范例,希望对你有所帮助
热心网友
时间:2023-11-06 15:44
在这里拿的(С;续啊31,c○м)应该会很棒的哦⊙∀⊙!