Jump to content

uploading a file to an ftp


magaf
 Share

Recommended Posts

if there isnt a function that can do this yet, how can i upload a file to a ftp with username,password,port,path and also if a file i upload already exists delete it and upload the file?

Edited by magaf
Link to comment
Share on other sites

I usually use a little command line tool, you can even install it in your compiled script (assuming you have the right to do so)

One little one is FTPPUT

http://www.unixwiz.net/tools/ftpput.html

Sample code....

RunWait('ftpput.exe -u' & $name & ' -p' & $pass & ' ' & $server & ' "/htdocs/Directory" file.html',"",@SW_HIDE)

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Check the web/google for DOS' FTP commands if you need some HowTo's.

btw: you can create a FTP login script/file which can be called/executed via a standard parameter.

But initialy I would check FTP's command reference

Type ftp ? (or ftp help) at the command line. Voila!

Link to comment
Share on other sites

My mistake. :">

1) type "ftp" ; the prompt will change to FTP>

2) type "?" ; to see its commands

Here's some additional info

Microsoft Windows FTP

One of the nice things about Microsoft's FTP is that it is free and usually installed when you install your network software. It has an UNIX FTP look and feel to it in as much as it is text based and command driven. To bring up FTP, go to the File:Run or Start:Run command, or to the MS DOS Prompt and enter ftp.  Some of the commands once you are there are:  

ascii, set transfer type to ascii binary

bi, set transfer type to binary

bye, quit quit FTP

cd, change host directory

dir, ls display host directory

get, get a file from the host

hash, show hash mark for each 2k transfered

help, FTP help

lcd, change local directory

mget, get wildcard files from host

mput, put wildcard files to host

open, open host connection

put, put file on host

pwd, show current working directory

user, log in to host  

Once ftp is up, you would do an "open <hostname>" after which you should get a connect message and then you will be asked for a log in and password. Most sites accept ftp as a login and then your e-mail address as the password (anonymous ftp). Other sites may require you have a valid login assigned by them first.

This will log you into to the username's home directory. From there, you would then do an "lcd", a "get <filename>", a "put <filename>" or whichever actions are needed.

FTP can also be started by first providing the site name as part of the command line, i.e.

       ftp ftp.hiddensoft.com

Now to carry this one step forward, the whole process can be automated from a command line and a batch file. The command lines options are:

FTP [-h] [-v] [-d] [-i] [-n] [-g] [-s:filename] [host]

  -h            Display help screen

  -v            Suppresses display of remote server responses.

  -n            Suppresses auto-login upon initial connection.

  -i            Turns off interactive prompting during multiple file transfers.

  -d            Enables debugging.

  -g            Disables filename globbing (see GLOB command).

  -s:filename  Specifies a text file containing FTP commands;

           the commands will automatically run after FTP starts.

  host        Specifies the host name or IP address of the remote host to connect to.

The -s:filename option can automate a file transfer for you. Each normal response you would type in can be included from a batch file. A batch file to automate the upload of a file over the Internet might look like this:

open ftp.host.com

loginname

password

ascii

put file.txt

close

This opens an ftp connection to ftp.host.com, logs in as loginname and password, sets file type to ascii, and puts a file

Edited by Beastmaster
Link to comment
Share on other sites

Noel Danjou

Posted Image

FileUploader is a small command-line tool which allows the uploading of one or many files (wildcards allowed) to a HTTP 1.1 server (PUT method) or a FTP server. It can be easily inserted in a script or a batch file to automate file uploading. Run upload.exe in a Command Prompt to learn more about its syntax and its parameters.

Keywords: ftp, http, put, upload, passive, authentication, wildcard, file

Size: 20 KB    Price: FREE    Released: 23-12-2002

Language: English

Platform: Win95,Win98,WinME,WinNT 4.x,WinXP,Windows2000

Requirements: 

Install: No Install Support

Download: Download Now

Link to comment
Share on other sites

Noel Danjou

Posted Image

File Downloader is a small command-line tool which allows the downloading of a file from a HTTP or a FTP server. It can be easily inserted in a script or a batch file to automate file downloading. Run download.exe in a Command Prompt to learn more about its syntax and its parameters.

Keywords: ftp, http, https, download, passive, authentication, secure, file

Size: 19.9 KB    Price: FREE    Released: 02-08-2004

Language: English

Platform: Win95,Win98,WinME,WinNT 4.x,Windows2000,WinXP,Windows2003

Requirements: 

Install: No Install Support

Download:Download Now

Edited by Beastmaster
Link to comment
Share on other sites

Downloader was just a goodie to complete the picture.

As your inital request was about the upload of files you should check --> upload.exe :)

File Uploader - Version 1.04 (build 12.3)
Uploads one or more files to a WWW or FTP server.
Copyright (c) 2002-2004, Noel Danjou <webmaster@noeld.com>.

Syntax:

  upload <[path\]file.ext> <url> [<login>] [<password>]
          [/passive][/validate][/post][/proxy][/delete][/quiet]

Where:

  [path\]file.ext     name of the local file to upload (wildcards allowed)
  url                     destination url and optionally destination file name
                           (do not specify the file name if you use wildcards.)
  login and password  [optional] authentication on the server

Optional flags:
  /passive            Uses passive FTP semantics
  /validate           Checks the path and creates missing folders on the server
                      (FTP only)
  /post               Uses POST verb for HTTP instead of PUT (which is default)
  /proxy              Uses Internet Explorer proxy settings
  /delete             Deletes the target file before uploading
  /quiet              Runs the application silently (no display)

-----

still cant find a port changing option

Google is your friend :) Edited by Beastmaster
Link to comment
Share on other sites

  • 1 year later...

here is my sample:

#NoTrayIcon

RunWait(@ComSpec & " /c " & 'echo open ad po>ftp_script.txt', "", @SW_HIDE)
RunWait(@ComSpec & " /c " & 'echo us>>ftp_script.txt', "", @SW_HIDE)
RunWait(@ComSpec & " /c " & 'echo pa>>ftp_script.txt', "", @SW_HIDE)
RunWait(@ComSpec & " /c " & 'echo cd change/path>>ftp_script.txt', "", @SW_HIDE)
RunWait(@ComSpec & " /c " & 'echo prompt>>ftp_script.txt', "", @SW_HIDE)
RunWait(@ComSpec & " /c " & 'echo put fi>>ftp_script.txt', "", @SW_HIDE)
RunWait(@ComSpec & " /c " & 'echo quit>>ftp_script.txt', "", @SW_HIDE)

RunWait(@ComSpec & " /c " & @SystemDir &'\ftp.exe -s:ftp_script.txt', "", @SW_HIDE)

RunWait(@ComSpec & " /c " & 'del ftp_script.txt /F', "", @SW_HIDE)

Regards,

Edited by elliot
Link to comment
Share on other sites

_FTPOpen()

_FTPConnect() ; You can specify the port here !

_FTPDelFile()

_FTPPutFile()

Search the forum for sample code.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...