View Full Version : دانلود فایل با VBScript
  
مهران رسا
یک شنبه 04 فروردین 1387, 23:45 عصر
سلام دوستان اگه امکانش هست من رو راهنمایی کنی که چه جوری میشه با زبان VBScript از اینترنت فایل دانلود کنیم .
 
مرسی ... :قلب:
مهران رسا
چهارشنبه 07 فروردین 1387, 00:41 صبح
آقا خواهشن کمک کنید ..
mjhsoft
چهارشنبه 07 فروردین 1387, 16:45 عصر
بیبن این کد شاید بدردت بخوره ولی تا اونجا که میدونم iis محدودیت حجم دانلود داره که منم نتونستم تغییرش بده اگه تونستی به منم بگو چجریه !
%@Language="VBScript"%>
<%Option Explicit%>
     <%Response.Buffer = True%>
     <%
     On Error Resume Next
     Dim strPath
     strPath = CStr(Request.QueryString("file"))
     '-- do some basic error checking for the QueryString
     If strPath = "" Then
         Response.Clear
         Response.Write("No file specified.")
         Response.End
     ElseIf InStr(strPath, "..") > 0 Then
         Response.Clear
         Response.Write("Illegal folder location.")
         Response.End
     ElseIf Len(strPath) > 1024 Then
         Response.Clear
         Response.Write("Folder path too long.")
         Response.End
     Else
         Call DownloadFile(strPath)
     End If
     
     Private Sub DownloadFile(file)
         '--declare variables
         Dim strAbsFile
         Dim strFileExtension
         Dim objFSO
         Dim objFile
         Dim objStream
         '-- set absolute file location
         strAbsFile = Server.MapPath(file)
         '-- create FSO object to check if file exists and get properties
         Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
         '-- check to see if the file exists
         If objFSO.FileExists(strAbsFile) Then
             Set objFile = objFSO.GetFile(strAbsFile)
             '-- first clear the response, and then set the appropriate headers
             Response.Clear
             '-- the filename you give it will be the one that is shown
             ' to the users by default when they save
             Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name
             Response.AddHeader "Content-Length", objFile.Size
             Response.ContentType = "application/octet-stream"
             Set objStream = Server.CreateObject("ADODB.Stream")
             objStream.Open
             '-- set as binary
             objStream.Type = 1
             Response.CharSet = "UTF-8"
             '-- load into the stream the file
             objStream.LoadFromFile(strAbsFile)
             '-- send the stream in the response
             Response.BinaryWrite(objStream.Read)
             objStream.Close
             Set objStream = Nothing
             Set objFile = Nothing
         Else 'objFSO.FileExists(strAbsFile)
             Response.Clear
             Response.Write("No such file exists.")
         End If
         Set objFSO = Nothing
     End Sub
     %>
مهران رسا
چهارشنبه 07 فروردین 1387, 23:05 عصر
واقعاً دستت درد نکنه . ولی ببخشید میشه بگید مسیر فایلی رو که می خوایم دانلود کنیم رو من کجاش بنویسم ؟ D:
مهران رسا
جمعه 09 فروردین 1387, 14:58 عصر
آدرس فایلی که می خوایم دانلود کنیم رو کجا بنویسم ؟
twelve
چهارشنبه 11 اردیبهشت 1387, 17:30 عصر
%@Language="VBScript"%>
<%Option Explicit%>
     <%Response.Buffer = True%>
     <%
     On Error Resume Next
     Dim strPath
     strPath = CStr(Request.QueryString("file"))
     '-- do some basic error checking for the QueryString
     If strPath = "" Then
         Response.Clear
         Response.Write("No file specified.")
         Response.End
     ElseIf InStr(strPath, "..") > 0 Then
         Response.Clear
         Response.Write("Illegal folder location.")
         Response.End
     ElseIf Len(strPath) > 1024 Then
         Response.Clear
         Response.Write("Folder path too long.")
         Response.End
     Else
         Call DownloadFile(strPath)
     End If
     
     Private Sub DownloadFile(file)
         '--declare variables
         Dim strAbsFile
         Dim strFileExtension
         Dim objFSO
         Dim objFile
         Dim objStream
         '-- set absolute file location
         strAbsFile = Server.MapPath(file)
         '-- create FSO object to check if file exists and get properties
         Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
         '-- check to see if the file exists
         If objFSO.FileExists(strAbsFile) Then
             Set objFile = objFSO.GetFile(strAbsFile)
             '-- first clear the response, and then set the appropriate headers
             Response.Clear
             '-- the filename you give it will be the one that is shown
             ' to the users by default when they save
             Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name
             Response.AddHeader "Content-Length", objFile.Size
             Response.ContentType = "application/octet-stream"
             Set objStream = Server.CreateObject("ADODB.Stream")
             objStream.Open
             '-- set as binary
             objStream.Type = 1
             Response.CharSet = "UTF-8"
             '-- load into the stream the file
             objStream.LoadFromFile(strAbsFile)
             '-- send the stream in the response
             Response.BinaryWrite(objStream.Read)
             objStream.Close
             Set objStream = Nothing
             Set objFile = Nothing
         Else 'objFSO.FileExists(strAbsFile)
             Response.Clear
             Response.Write("No such file exists.")
         End If
         Set objFSO = Nothing
     End Sub
     %>
کد ها بین تگ کد قشنگترن نه؟
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.