在asp.net中我想把客户端例如C:\1.jpg上传到服务器固定文件夹(loadimg)谁能帮忙谢谢!
不用"<input type=file>"
不用"<input type=file>"
解决方案 »
- 多域名,多语言,如何实现同步登录
- Repeater 中控件的问题
- 怎样实现这样的排序SELECT * FROM TABLE WHERE ID IN (-1,200795,200032,200037,200048,200063)
- asp.net 如何实现异步监听客户端?
- 【问两个简单的问题!】
- 程序转移数据库出现错误
- 谁给我讲一下支付宝接口的问题呢
- 在线等~~一个ASP。NET 程序~请看源程序。~~
- 都来看看:datagrid中dropdownlist的问题!
- 删除功能的label怎么做?如图
- 时间格式在SQL中如何比较(实在是没办法了,希望大家帮个忙)?
- 求一个新闻或文章管理的源码.(含cs代码)
<asp:FileUpload ID="fufile" runat="server" />
<asp:Button ID="btnupfile" runat="server" OnClick="btnupfile_Click" Text="UPLOAD" />
<asp:Label ID="lbmsg" runat="server" Text="Label"></asp:Label>cs code:
protected void btnupfile_Click(object sender, EventArgs e)
{
bool fileOk = false;
string path = Server.MapPath("~/uploadImages/");
if (fufile.HasFile)
{
string fileExtension = System.IO.Path.GetExtension(fufile.FileName).ToLower();
string[] allowExtentsion = { ".gif", ".jpg" };
for (int i= 0;i < allowExtentsion.Length;i++)
{
if (fileExtension == allowExtentsion[i])
{
fileOk = true;
}
}
}
if (fileOk)
{
try
{
fufile.PostedFile.SaveAs(path + fufile.FileName);
lbmsg.Text = "file UPLOADED!";
}catch(Exception EX)
{
lbmsg.Text="file could not be uploaded";
}
}else {
lbmsg.Text="文件类型不对";
}
}