用FileInput控件,搜索一下,例子很多
解决方案 »
- Cookies如何删除子键
- 关于asp.net刷新后,事件重新执行的问题
- 求教各位高手帮忙看一下下面的代码,注册页面里的“注册”按钮的Click事件,点击后不能向用户表里插入信息!!!!
- 求GridView导出Excel较好的方法,及常见问题汇总
- 海量数据导出到Excel
- 谁能一句话说清楚membership,role,profile的关系
- 怎样使用java实现这样的功能
- 求救:在asp.net中怎样实现类属性?
- 怎样让textbox中的文字居中显示???程序中设ForeColor好像没用,字体颜色不变?
- 关于TreeView的一个小问题
- 怎样检查一个网页是否已打开,急!顶者有分。。。
- 谁能提供一些关于asp.net中页面间值传递的例子和代码?
FileInfo.Visible = False
Exit Sub
Else
FileInfo.Visible = True
FDisplay1.Visible = True
End IfFSize.Text ="上传文件大小"+ CStr(FileUp.PostedFile.ContentLength/1024)+"KB"
string strFile = fImage.PostedFile.FileName.Trim();
strFile = System.IO.Path.GetFileName(strFile);
string strPath = Server.MapPath("../CompImage/");
string strPathFile = strPath.Trim() + strFile.Trim();
fImage.PostedFile.SaveAs(strPathFile);
IOAction.FileAction.SavePostedFileToExsistDirectory( System.Web.HttpContext.Current.Server.MapPath("upload\\"))//自定义类
namespace IOAction
{
/// <summary>
/// 自定义的文件操作类
/// </summary>
public class FileAction
{
public FileAction()
{
//
// TODO: 在此处添加构造函数逻辑
//
} //把上传文件存入已存在路径
public static string SavePostedFileToExsistDirectory(string pathtosave, System.Web.HttpPostedFile postedfile, bool overwrite)
{
string savedFileName = pathtosave + System.IO.Path.GetFileName(postedfile.FileName.Trim()); if (overwrite)
{
postedfile.SaveAs(savedFileName);
}
else
{
int fileSuffix = 1;
while(File.Exists(savedFileName))
{
savedFileName = Path.Combine(pathtosave, Path.GetFileNameWithoutExtension(postedfile.FileName) + "[" + fileSuffix + "]" + Path.GetExtension(postedfile.FileName));
fileSuffix ++;
}
postedfile.SaveAs(savedFileName);
} return savedFileName; }
}
}