asp.net slickupload asp.net slickupload 使用方法(文件上传)
人气:0想了解asp.net slickupload 使用方法(文件上传)的相关内容吗,在本文为您仔细讲解asp.net slickupload的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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();
}
加载全部内容