asp.net slickupload 使用方法(文件上传)
作者:
asp.net下使用slickupload上传文件的代码
在web.config中添加:
<httpModules >
<add name="HttpUploadModule" type="Krystalware.SlickUpload.HttpUploadModule, Krystalware.SlickUpload" / >
</httpModules >
2、在项目中添加对Krystalware.SlickUpload.DLL的引用。
3、在页面上放控件:HtmlInputFile fileUpload;
4、后代码如下:
private void RedirectToNewUpload()
{
Response.Redirect("PhotoInfo.aspx?uploadId=" Guid.NewGuid().ToString() "&action=" strViewType "&id=" BTSID);
}
private void Page_Load(object sender, System.EventArgs e)
{
...
UploadedFileCollection parts = HttpUploadModule.GetUploadedFiles();
if (Request.QueryString["uploadId"] == null)
RedirectToNewUpload();
...
}
private void btUpload_Click(object sender, System.EventArgs e)
{
UploadedFileCollection parts = HttpUploadModule.GetUploadedFiles();
string uppath = System.Configuration.ConfigurationSettings.AppSettings["UploadPath"];
try
{
if (parts != null)
{
foreach (UploadedFile part in parts)
{
if(part.ContentLength==0)
return;
if(File.Exists(uppath part.ClientName))
{
File.Delete(uppath part.ClientName);
}
part.SaveAs(uppath part.ClientName);
Byte[] FileByteArray = new Byte[part.ContentLength]; //图象文件临时储存Byte数组
FileStream fs = new FileStream(uppath part.ClientName, FileMode.Open);
fs.Read(FileByteArray,0,Convert.ToInt32(part.ContentLength));
fs.Close();
File.Delete(uppath part.ClientName);
//使用FileByteArray来保存得到的数据
}
RedirectToNewUpload();
}
<httpModules >
<add name="HttpUploadModule" type="Krystalware.SlickUpload.HttpUploadModule, Krystalware.SlickUpload" / >
</httpModules >
2、在项目中添加对Krystalware.SlickUpload.DLL的引用。
3、在页面上放控件:HtmlInputFile fileUpload;
4、后代码如下:
复制代码 代码如下:
private void RedirectToNewUpload()
{
Response.Redirect("PhotoInfo.aspx?uploadId=" Guid.NewGuid().ToString() "&action=" strViewType "&id=" BTSID);
}
private void Page_Load(object sender, System.EventArgs e)
{
...
UploadedFileCollection parts = HttpUploadModule.GetUploadedFiles();
if (Request.QueryString["uploadId"] == null)
RedirectToNewUpload();
...
}
private void btUpload_Click(object sender, System.EventArgs e)
{
UploadedFileCollection parts = HttpUploadModule.GetUploadedFiles();
string uppath = System.Configuration.ConfigurationSettings.AppSettings["UploadPath"];
try
{
if (parts != null)
{
foreach (UploadedFile part in parts)
{
if(part.ContentLength==0)
return;
if(File.Exists(uppath part.ClientName))
{
File.Delete(uppath part.ClientName);
}
part.SaveAs(uppath part.ClientName);
Byte[] FileByteArray = new Byte[part.ContentLength]; //图象文件临时储存Byte数组
FileStream fs = new FileStream(uppath part.ClientName, FileMode.Open);
fs.Read(FileByteArray,0,Convert.ToInt32(part.ContentLength));
fs.Close();
File.Delete(uppath part.ClientName);
//使用FileByteArray来保存得到的数据
}
RedirectToNewUpload();
}
您可能感兴趣的文章:
- 收藏的asp.net文件上传类源码
- Asp.net 文件上传类(取得文件后缀名,保存文件,加入文字水印)
- asp.net 大文件上传 之 改版了的SlickUpload.HttpUploadModule(Krystalware.SlickUpload.dll)
- asp.net 2.0的文件上传(突破上传限制4M)
- asp.net 文件上传与刷新与asp.net页面与iframe之间的数据传输
- asp.net 模拟提交有文件上传的表单(通过http模拟上传文件)
- asp.net 多文件上传,兼容IE6/7/8,提供完整代码下载
- asp.net 简便无刷新文件上传系统
- asp.net(c#)开发中的文件上传组件uploadify的使用方法(带进度条)
- 用Fine Uploader+ASP.NET MVC实现ajax文件上传[代码示例]
- Asp.Net 无刷新文件上传并显示进度条的实现方法及思路
- ASP.NET MVC处理文件上传的小例子
- asp.net 文件上传实例汇总
- asp.net文件上传示例分享
- asp.net fileupload控件上传文件与多文件上传
- ASP.NET实现的简单易用文件上传类
- ASP.NET对大文件上传的解决方案
- asp.net批量多选文件上传解决方案
- ASP.NET设计FTP文件上传的解决方案
- asp.net文件上传带进度条实现案例(多种风格)
- asp.net文件上传解决方案(图片上传、单文件上传、多文件上传、检查文件类型)