去实现"下载中要给出进度(已下载文件/总文件个数)"倒问题不大.
写出这个东西,代码少说也有几百行,挺多的, 估计也没有人帮你写..
如果你懂一点ASP
你自己可参考 一些知名的文章系统程序中的采集工具 或 者参考小偷程序代码, 中有对xmlhttp等技术封装包.. 直接调用和使用就行..
#region 下载图片并上传至图片服务器public string SaveUrlPics( string strHTML, string path)
{
string picserver = new CommonBLL().GetItemValue("PICSERVER")//获取图片服务器地址
string[] imgurlAry = GetImgTag(strHTML)//获取文章中的图片地址
try
{
WebClient wc = new WebClient()
for (int i = 0i <imgurlAry.Lengthi++)
{
//暂时处理避免多次进行添加处理 不处理本机的情况
if(imgurlAry[i].IndexOf(picserver)<0)
{
string preStr = DateTime.Now.ToString("yyyyMMddHHmmssfff")
preStr = preStr + imgurlAry[i].Substring(imgurlAry[i].LastIndexOf("."))//获取图片的属性 生成图片名称
//下载的图片存储在TEMP文件夹中
wc.DownloadFile(imgurlAry[i], HttpContext.Current.Server.MapPath(path) + "/" + preStr)
//把图片上传至图片服务器
preStr = picserver + "/" + upImg(preStr, dropArtType.SelectedValue)
strHTML = strHTML.Replace(imgurlAry[i], preStr)
}
}
}
catch (Exception ex)
{
ShowMessage(ex.Message)
}
return strHTML
}
#endregion
调用response.Write("<a href=down.asp?filename="&UpLoadPath&ls_array(i+1)&">"&ls_array
(i)&"</td></tr>")
down.asp文件内容如下:
<%
Const FilePath = "UploadFile/" '文件存放路径
From_url = Cstr(Request.ServerVariables("HTTP_REFERER"))
Serv_url = Cstr(Request.ServerVariables("SERVER_NAME"))
Function GetFileName(longname)'/folder1/folder2/file.asp=>file.asp
while instr(longname,"/")
longname = right(longname,len(longname)-1)
wend
GetFileName = longname
End Function
Dim Stream
Dim Contents
Dim FileName
Dim TrueFileName
Dim FileExt
Const adTypeBinary = 1
FileName = Request.QueryString("FileName")
if FileName = "" Then
Response.Write "无效文件名!"
Response.End
End if
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
Response.Clear
if lcase(right(FileName,3))="gif" or lcase(right(FileName,3))="jpg" or lcase(right(FileName,3))="png" then
Response.ContentType = "image/*" '对图像文件不出现下载对话框
else
Response.ContentType = "application/ms-download"
end if
Response.AddHeader "content-disposition", "attachmentfilename=" &GetFileName(Request.QueryString("FileName"))
Set Stream = server.CreateObject("ADODB.Stream")
Stream.Type = adTypeBinary
Stream.Open
TrueFileName= FilePath &FileName
Response.Write TrueFileName
Response.End
Stream.LoadFromFile Server.MapPath(TrueFileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)