Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:03:09+00:00 2026-06-02T15:03:09+00:00

I have a vb script to download a file from an URL – the

  • 0

I have a vb script to download a file from an URL – the url is an ftp site: ftp://ftp.zois.co.uk/pub/jcp/

I need to download the file specified below. The script gets the file but contents are empty – tried with other CSV files on the ftp site and same problem.

Can anyone help please?

HTTPDownload "ftp://ftp.zois.co.uk/pub/jcp/JCP-scrape-2012-04-24.csv", "C:\"

Sub HTTPDownload( myURL, myPath )
' This Sub downloads the FILE specified in myURL to the path specified in myPath.
'
' myURL must always end with a file name
' myPath may be a directory or a file name; in either case the directory must exist
'
 ' Written by Rob van der Woude
' http://www.robvanderwoude.com
'
    ' Based on a script found on the Thai Visa forum
' http://www.thaivisa.com/forum/index.php?showtopic=21832

' Standard housekeeping
Dim i, objFile, objFSO, objHTTP, strFile, strMsg
Const ForReading = 1, ForWriting = 2, ForAppending = 8

' Create a File System Object
Set objFSO = CreateObject( "Scripting.FileSystemObject" )

' Check if the specified target file or folder exists,
' and build the fully qualified path of the target file
If objFSO.FolderExists( myPath ) Then
    strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) )
ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then
    strFile = myPath
Else
    WScript.Echo "ERROR: Target folder not found."
    Exit Sub
End If

' Create or open the target file
Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True )

' Create an HTTP object
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )

' Download the specified URL
objHTTP.Open "GET", myURL, False
objHTTP.Send

' Write the downloaded byte stream to the target file
For i = 1 To LenB( objHTTP.ResponseBody )
    objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
Next

' Close the target file
objFile.Close( )
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:03:10+00:00Added an answer on June 2, 2026 at 3:03 pm

    That code is for downloading from HTTP. FTP is not HTTP. FTP does have a get command but if nothing else the port is almost definitely different and since there’s no port specified, it’s almost definitely using 80 for HTTP, while FTP uses 21 as its default. Here is a similar example using ftp. There may be other/better FTP components than what it uses, but that’s the root of your problem. Also note that it’s not really getting your file, it’s just creating a file that never gets written to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to daily run a script that will download a file from a
I have this script below, where I want to download a pdf from a
Hi I need to download a file from a site with forms authentication and
i have to download a file created from a php script. i tried this:
Hey everyone, I have written a script that downloads a zip file from a
I have a script that download's files from a server, all works nice. But
I have a PHP script that produces a .CSV export file from a MySQL
I have a PHP script that creates an xml file from the db. I
I have a script I'm writing to batch download images from an imageboard via
i wanna download any file from any website with my forcedownload script. simple script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.