有哪位仁兄实现过类似于163邮箱那样的添加附件功能啊,就是选择完文件后就能直接上传
解决方案 »
- c# print2flash 转换命令
- VS2005安装的问题
- 菜鸟的菜问题,还请高手们多多指教
- 更新事件中判断输入只能为数字
- ReportView 显示Reporting Service 报表问题(难呀!)
- 怎么给网页中的www和http这样的网址自动加链接?
- 从数据库中读数据是,空值的判断?
- 帮我给点建议好吗,谢谢!我正在ASP.NET的门前徘徊……
- 求ASP.NET开源商城程序 求推荐
- 各位谁有好的按钮图片(add,del,edit等),请给小弟发来一些!急用!
- Access Insert 语法错误!!!!!!!!
- 当前页面指定某class的public变量赋值后,为什么在另一个页面该变量也赋值了?
phyPath //你要复制到服务器的路径.或者你就用FileUpload控件
function AddRow()
{
var newRow = document.getElementById("row").cloneNode(true);
table1.appendChild(newRow);
}
</script>http://www.cnblogs.com/tangdebing/archive/2008/01/08/728954.html
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;namespace SqlBLL
{
public class FileUp
{
/// <summary>
/// 传递上传控件,实习上传程序
/// </summary>
/// <param name="fiu">上传控件</param>
/// <param name="filePath">文件名虚拟路径对应的物理路径
/// eg:
/// Server.MapPath("~/filepath")</param>
/// <param name="errmsg">输出参数 错误信息发生错误返回null</param>
/// <returns></returns>
public static string GetFileUp(System.Web.UI.WebControls.FileUpload fiu, string filePath, out string errmsg)
{
string imageName = null;
if (fiu.HasFile)
{
bool fileIsTrue = false;
string fileExpand = Path.GetExtension(fiu.FileName).ToLower().Trim();
//定义扩展名的格式
string[] ExpandName = { ".gif", ".jpg", ".bmp", ".png" };
for (int i = 0; i < ExpandName.Length; i++)
{
if (ExpandName[i] == fileExpand)
fileIsTrue = true;
}
if (fileIsTrue)
{
//判断路径是否存在
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
imageName = photoName() + fileExpand;
fiu.SaveAs(filePath +imageName);
}
else
{
errmsg = "只能上传图片格式的文件";
return null;
}
}
else
{
errmsg = "文件不存在";
return null;
}
errmsg = "";
return imageName;
} /// <summary>
/// 生成随机名称
/// </summary>
/// <returns></returns>
public static string photoName()
{
string datetime = Convert.ToString(DateTime.Now);
//文件名
string filename = null;
for (int i = 0; i < datetime.Length; i++)
{
if (datetime[i] >= '0' && datetime[i] <= '9')
filename += datetime[i];
}
return filename;
}
}
}