Upload files to FTP or WEB Disk (1 Viewer)

smig

Registered User.
Local time
Today, 12:31
Joined
Nov 25, 2009
Messages
2,209
Hi

I'm looking for code to upload files to FTP or WEB disk (I can create them both)
If it's a WEB disk I don't want to map it in any way, just put the files in it

Thank you
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:31
Joined
Sep 12, 2006
Messages
15,658
I create a text file with the commands to run all the ftp statements, and then call it with this ExecCommand statement. I am not sure where I found the ExecCommand code, as it includes a fair bit of support code. I hope this helps

The ftp script executes the log in, sets default folders, and then does gets/puts etc as required. It took a fair while to reach the final version, I recall. We had issues with ports not being open, and so on.

Call ExecCommand("C:\Windows\System32\ftp.exe -ns:" & Chr(34) & scriptfolder & ScriptFileSend & Chr(34), vbMinimizedFocus)

I actually do a belt and braces thing. If I am doing a get from an ftp site, I collect an ls first of the files to be collected. Then I get them. Then I make sure that I did get all of the files I expected to get, and only then do I delete the files from the ftp site.
 
Last edited:

smig

Registered User.
Local time
Today, 12:31
Joined
Nov 25, 2009
Messages
2,209
I create a text file with the commands to run all the ftp statements, and then call it with this ExecCommand statement. I am not sure where I found the ExecCommand code, as it includes a fair bit of support code. I hope this helps

The ftp script executes the log in, sets default folders, and then does gets/puts etc as required. It took a fair while to reach the final version, I recall. We had issues with ports not being open, and so on.

Call ExecCommand("C:\Windows\System32\ftp.exe -ns:" & Chr(34) & scriptfolder & ScriptFileSend & Chr(34), vbMinimizedFocus)
Thanks

I'm trying to use the ftp.exe window now
I manage to connect to the ftp server, but unable to upload a file.
the file will be created empty, and I get an "425 no data connection" error
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:31
Joined
Sep 12, 2006
Messages
15,658
I forget all the commands offhand. have to check each time
you have a command to set the local folder on the pc.
another command to set the folder on the ftp site (I forget the slight syntax difference without offhand)
then get filename to get a file or get * to get all the files (I think)
the path on the ftp server may need the "wrong" slash. (again just not sure offhand)

ls should give you a file listing on screen. you may need a pipe command to save it though either ls | "testfile" or ls > "testfile"

you aren't trying to save to the C:\ folder are you? that might fail anyway.

here's a sample script to send a single file.

OPEN ftp url
USER username password
quote pasv
cd /ftppath 'set the folder on the ftp server - it uses the "wrong" slash
lcd localpath ' set the folder on the pc
ascii
prompt
quote pasv 'not 100% sure what this does.
put localfilename 'send a file to the ftpserver
quote pasv
ls * listingname ' save a listing of the files on the ftpserver, to make sure the put worked.
bye
 
Last edited:

bastanu

AWF VIP
Local time
Today, 02:31
Joined
Apr 13, 2010
Messages
1,402
Here is an older file (mdb) I used to download files from FTP, the code is there to upload as well.

Cheers,
 

Attachments

  • VBA_FTP.mdb
    404 KB · Views: 109

Users who are viewing this thread

Top Bottom