Jump to content

_FTPPutFile is not working


Recommended Posts

Hi,

I digged into almost all the posts related to FTP for no luck :D , On calling the FTPPutFile, it returns 0.

I think I have included all the necessary stuff such as wininet.dll etc. I am able to Open the Connection and Connect to the remote FTP server successfully.

Can you please point me out the mistake I am committing in the below code:

#include <FTP.au3>

$close = DllOpen('Wininet.dll')

$server = 'ip address'

$username = 'username'

$pass = '******'

MsgBox(1,"Hi",$close)

$Open = _FTPOpen('MyFTP','','','',1)

MsgBox(1,"Hi",$Open)

Sleep(300)

$Conn = _FTPConnect($Open, $server, $username, $pass, 0, 1, 0x08000000,0)

MsgBox(1,"Conn",$Conn)

Sleep(300)

$Ftpp = _FTPPutFile($Conn, 'C:\WINDOWS\Notepad.exe', '/back/')

MsgBox(1,"End", $Ftpp)

$Ftpc = _FTPClose($close)

Thanks in advance :o

Link to comment
Share on other sites

Hi,

I digged into almost all the posts related to FTP for no luck :D , On calling the FTPPutFile, it returns 0.

I think I have included all the necessary stuff such as wininet.dll etc. I am able to Open the Connection and Connect to the remote FTP server successfully.

Can you please point me out the mistake I am committing in the below code:

Thanks in advance :o

I can't test it at the moment, but I am using the same functions in a script of mine. The difference being that I used:

$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $ServerName, $Username, $Password)
_FTPClose($Open)
DllClose($Close)

Also "wininet.dll" is all lowercase, but I am not sure it's case sensitive. (guess it's not if _FTPOpen() works.

Have you tried testing the script without the special flags? (I'm not sure what they do, or how badly you need them, but they seem to be the major difference between our scripts.)

P.S. use code tags. Some users won't respond to posts with a bunch of raw code in it.

edit: oh and make sure your directories exist, or are created and capitalised correctly.

Edited by Tvern
Link to comment
Share on other sites

Hi,

Ya, had tested removing the special flags. Someone had posted that it worked when they added the special flags. So, even I added(copy cat):D . _FTPOpen() is not creating any problem because its opening and connecting to the server. I am facing problem only in uploading the files i.e., ftpput(). All the files are present in the working directory....No clue, what is creating the problem :o

Link to comment
Share on other sites

Hi,

I digged into almost all the posts related to FTP for no luck :D , On calling the FTPPutFile, it returns 0.

I think I have included all the necessary stuff such as wininet.dll etc. I am able to Open the Connection and Connect to the remote FTP server successfully.

Can you please point me out the mistake I am committing in the below code:

#include <FTP.au3>

$close = DllOpen('Wininet.dll')

$server = 'ip address'

$username = 'username'

$pass = '******'

MsgBox(1,"Hi",$close)

$Open = _FTPOpen('MyFTP','','','',1)

MsgBox(1,"Hi",$Open)

Sleep(300)

$Conn = _FTPConnect($Open, $server, $username, $pass, 0, 1, 0x08000000,0)

MsgBox(1,"Conn",$Conn)

Sleep(300)

$Ftpp = _FTPPutFile($Conn, 'C:\WINDOWS\Notepad.exe', '/back/')

MsgBox(1,"End", $Ftpp)

$Ftpc = _FTPClose($close)

Thanks in advance :o

I'm not sure that this will work-

[b][color="#0000ff"]$Ftpp = _FTPPutFile($Conn, 'C:\WINDOWS\Notepad.exe', '/back/')[/color][/b]

but when I use _FTPPutFile I always specify the file to be written, and I also always add the flag as follows

[color="#000000"]$Ftpp = _FTPPutFile($Conn, 'C:\WINDOWS\Notepad.exe', '/back/Notepad.exe',0x08000000)[/color]

Don't forget that names on the server are probably case sensitive.

Also, try with some other file name in case the server doesn't allow exe files.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 1 month later...

On my system, I had problems until I found out the local file was in use by another app. When I closed the other app, the xfer worked. Also, the destination filename must be spelled out, you can't just use the destination directory name. Try simplifying your parameters by sending a simple file from your root drive to the root of the server like this:

$Ftpp = _FtpPutFile($Conn, 'c:\test.htm',  '/test.htm')
Link to comment
Share on other sites

#Include <FTP.au3>

Const $Host = ''
Const $Login = ''
Const $Password = ''

Const $LocalFile = 'C:\WINDOWS\Notepad.exe'
Const $RemoteFile = 'Notepad.exe'

Local $hFtp, $hSession

_FTP_Startup()
ConsoleWrite(@error & @CR)
$hFtp = _FTP_Open('MyFtp')
ConsoleWrite(@error & @CR)
$hSession = _FTP_Connect($hFtp, $Host, $Login, $Password)
ConsoleWrite(@error & @CR)
_FTP_PutFile($hSession, $LocalFile, $RemoteFile)
ConsoleWrite(@error & @CR)
_FTP_Disconnect($hSession)
_FTP_Close($hFtp)
_FTP_Shutdown()

Use this FTP.au3.

If you are not working, the problem in your FTP-server. Check mode (active or passive), port (default is 21), etc., dude.

Edited by Yashied
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...