fileupload控件在修改的时候路径是否可以显示 fileupload控件在修改的时候路径是否可以显示? //不明白 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected void Button2_Click(object sender, EventArgs e) { if(UpLoadPic()) { Response.Write(FileUpload1.PostedFile.FileName.ToString()); } }private string[] AcceptedFileTypes = new string[] { "jpg", "jpeg", "jpe" ,"png","p2p"}; public bool UpLoadPic()//上传 { bool ifSucess = false; if (FileUpload1.PostedFile.ContentLength > 0) { if (IsValidFileType(FileUpload1.PostedFile.FileName)) { if (FileUpload1.PostedFile.ContentLength < 1024 * 2000) { string fullName = FileUpload1.PostedFile.FileName; string newName = System.DateTime.Now.ToString("yyyyMMddhhmmss") + fullName.Substring(fullName.LastIndexOf(".")); string path = Server.MapPath("UpLoad"); FileUpload1.SaveAs(path + "/" + newName); Label1.Text = newName; Image1.ImageUrl = "UpLoad/" + newName; Image1.Visible = true; ifSucess = true; } else { Response.Write("<script>alert('出错了!上传文件太大!')</script>"); } } else { ifSucess = false; Response.Write("<script>alert('出错了!上传文件格式不对!')</script>"); } } else { Response.Write("<script>alert('出错了!上传文件不能为空!')</script>"); } return ifSucess; } private bool IsValidFileType(string FileName)//图片格式检验 { string ext = FileName.Substring(FileName.LastIndexOf(".") + 1, FileName.Length - FileName.LastIndexOf(".") - 1); for (int i = 0; i < AcceptedFileTypes.Length; i++) { if (ext.ToLower() == AcceptedFileTypes[i]) { return true; } } return false; } 不能 这个控件的地址属性 是只读的 ,不可以赋值 你可以用一个label显示哪个地址啊 关于Lucene.net盘古分词的资料或实例 求字符串拆分方法 十万火急,我的这个消息框怎显示在服务器上了?我要显示在客户端才对,怎么改? 新手求两道题,很简单的。。。。。 .NET中的XML的半技术问题 下载文件,用filestream方法输出到浏览器时,在浏览器中能保存但是不能打开? 提问一个关于linkbutton点击无反映的问题。 html标签无法在web页面输出,只输出代码 如何设计让水晶报表字段和数据显示在同一行? asp.net MVC同一站点,不同用户空间使用独立域名 主题中CSS与页面中Javascript冲突 一个很有深度的Gridview问题,大家都来讨论一下!
{
if(UpLoadPic())
{
Response.Write(FileUpload1.PostedFile.FileName.ToString());
}
}private string[] AcceptedFileTypes = new string[] { "jpg", "jpeg", "jpe" ,"png","p2p"}; public bool UpLoadPic()//上传
{
bool ifSucess = false;
if (FileUpload1.PostedFile.ContentLength > 0)
{
if (IsValidFileType(FileUpload1.PostedFile.FileName))
{ if (FileUpload1.PostedFile.ContentLength < 1024 * 2000)
{ string fullName = FileUpload1.PostedFile.FileName;
string newName = System.DateTime.Now.ToString("yyyyMMddhhmmss") + fullName.Substring(fullName.LastIndexOf("."));
string path = Server.MapPath("UpLoad");
FileUpload1.SaveAs(path + "/" + newName);
Label1.Text = newName;
Image1.ImageUrl = "UpLoad/" + newName;
Image1.Visible = true;
ifSucess = true;
}
else
{
Response.Write("<script>alert('出错了!上传文件太大!')</script>");
}
}
else
{
ifSucess = false;
Response.Write("<script>alert('出错了!上传文件格式不对!')</script>");
}
}
else
{
Response.Write("<script>alert('出错了!上传文件不能为空!')</script>");
}
return ifSucess;
}
private bool IsValidFileType(string FileName)//图片格式检验
{
string ext = FileName.Substring(FileName.LastIndexOf(".") + 1, FileName.Length - FileName.LastIndexOf(".") - 1);
for (int i = 0; i < AcceptedFileTypes.Length; i++)
{
if (ext.ToLower() == AcceptedFileTypes[i])
{
return true;
}
}
return false;
}