asp.net slickupload 使用方法(文件上传)
程序员文章站
2024-03-11 20:00:43
在web.config中添加:
在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();
}
上一篇: Yii2.0多文件上传实例说明
推荐阅读
-
asp.net slickupload 使用方法(文件上传)
-
asp.net 大文件上传 之 改版了的SlickUpload.HttpUploadModule(Krystalware.SlickUpload.dll)
-
asp.net 2.0的文件上传(突破上传限制4M)
-
asp.net javascript 文件无刷新上传实例代码第1/2页
-
ASP.NET 常用 文件上传方法第1/2页
-
asp.net neatUpload 支持大文件上传组件
-
asp.net slickupload 使用方法(文件上传)
-
asp.net 大文件上传 之 改版了的SlickUpload.HttpUploadModule(Krystalware.SlickUpload.dll)
-
asp.net 文件上传 实时进度
-
asp.net 2.0的文件上传(突破上传限制4M)