qassam

_FTP_FilePut does not work !!

14 posts in this topic

hello all 

i wrote a little script for upload some folder from my computer to my FTP server it's working Except _FTP_FilePut i dont now why :(

this is my code 

#RequireAdmin
#include <FTPEx.au3>
 #include <Inet.au3>


$szMyDir = "C:\MyDesktop\MyFolder"

Local $sServer = '192.168.1.15'
Local $sUsername = 'username'
Local $sPass = 'pass'
local $file = _GetIP ()
Local $hOpen = _FTP_Open('upload')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
; ...

local $fuck =_FTP_DirCreate (  $hConn, $file )
local $fileput = _FTP_FilePut($hConn ,$szMyDir , $fuck )
Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)

help please 

Share this post


Link to post
Share on other sites



try to use some checking

for example _FTP_MSG()

and use _FTP_DirSetCurrent() before you want to create your new DIR

conclusion: as a normal FTP user you can not create dir at the top of DIR structure.

#RequireAdmin
#include <FTPEx.au3>
#include <Inet.au3>
#include <array.au3>


$szMyDir = "C:\MyDesktop\MyFolder"

Local $sServer = '192.168.1.205'
Local $sUsername = 'backup_user'
Local $sPass = 'xxxxx'
local $file = _GetIP ()
Global  $iError, $sMessage

Local $hOpen = _FTP_Open('upload')
_FTP_MSG()
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
; ...
_FTP_MSG()

_FTP_DirSetCurrent (  $hConn, '/ftp_shares/backup_user/' )
_FTP_MSG()
local $fuck =_FTP_DirCreate (  $hConn, $file )
_FTP_MSG()
local $fileput = _FTP_FilePut($hConn ,$szMyDir , $fuck )
_FTP_MSG()
Local $iFtpc = _FTP_Close($hConn)
_FTP_MSG()
Local $iFtpo = _FTP_Close($hOpen)
_FTP_MSG()


Func _FTP_MSG()
    _FTP_GetLastResponseInfo($iError,$sMessage)
    ConsoleWrite('$iError = ' & $iError & @CRLF & '$sMessage = ' & $sMessage & @CRLF)
EndFunc

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

 

try to use some checking

for example _FTP_MSG()

and use _FTP_DirSetCurrent() before you want to create your new DIR

conclusion: as a normal FTP user you can not create dir at the top of DIR structure.

#RequireAdmin
#include <FTPEx.au3>
#include <Inet.au3>
#include <array.au3>


$szMyDir = "C:\MyDesktop\MyFolder"

Local $sServer = '192.168.1.205'
Local $sUsername = 'backup_user'
Local $sPass = 'xxxxx'
local $file = _GetIP ()
Global  $iError, $sMessage

Local $hOpen = _FTP_Open('upload')
_FTP_MSG()
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
; ...
_FTP_MSG()

_FTP_DirSetCurrent (  $hConn, '/ftp_shares/backup_user/' )
_FTP_MSG()
local $fuck =_FTP_DirCreate (  $hConn, $file )
_FTP_MSG()
local $fileput = _FTP_FilePut($hConn ,$szMyDir , $fuck )
_FTP_MSG()
Local $iFtpc = _FTP_Close($hConn)
_FTP_MSG()
Local $iFtpo = _FTP_Close($hOpen)
_FTP_MSG()


Func _FTP_MSG()
    _FTP_GetLastResponseInfo($iError,$sMessage)
    ConsoleWrite('$iError = ' & $iError & @CRLF & '$sMessage = ' & $sMessage & @CRLF)
EndFunc

still the same problem !! my problem not with dircreate !! my problem with ftp put function does not work 

Edited by qassam

Share this post


Link to post
Share on other sites

what a file you want to put ?

MsgBox(0, '$szMyDir', $szMyDir)
MsgBox(0, '$fuck', $fuck)
local $fileput = _FTP_FilePut($hConn ,$szMyDir , $fuck )

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

 

what a file you want to put ?

MsgBox(0, '$szMyDir', $szMyDir)
MsgBox(0, '$fuck', $fuck)
local $fileput = _FTP_FilePut($hConn ,$szMyDir , $fuck )

RALLY im very sorry man :( i mean folder not file :( sorry for that mistake 

Share this post


Link to post
Share on other sites

You need to enumerate each file and copy them in a loop.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

look man this my idea exactly 

there are a file in my computer in ( c:/dd.rar ) i zipped the folder okay !!

i want to upload this folder from my PC to My FTP server in A specific folder on my server which created by local $fuck =_FTP_DirCreate (  $hConn, $file )

 

#RequireAdmin

#include <FTPEx.au3>
 #include <Inet.au3>
 
 
$szMyDir = "C:dd.rar"
 
Local $sServer = ''
Local $sUsername = ''
Local $sPass = ''
local $file = _GetIP()
Local $hOpen = _FTP_Open('upload')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
; ...
 
local $fuck =_FTP_DirCreate (  $hConn, $file )
 
local $fileput = _FTP_FilePut($hConn ,$szMyDir ,  )
Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)
 

when i run the script the folder created successfully but it's empty !!

Edited by qassam

Share this post


Link to post
Share on other sites

because you do not set destination

local $fileput = _FTP_FilePut($hConn ,$szMyDir ,  )

i think you should try this:

local $fileput = _FTP_FilePut($hConn ,$szMyDir , '/' & _GetIP() & '/dd.rar' )

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

 

because you do not set destination

local $fileput = _FTP_FilePut($hConn ,$szMyDir ,  )

i think you should try this:

local $fileput = _FTP_FilePut($hConn ,$szMyDir , '/' & _GetIP() & '/dd.rar' )

ur the man , thanks maan very much working now 

Share this post


Link to post
Share on other sites

you're welcome


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

This topic isn't too old...  :  so I was hoping you could help me out with the same issue!

My connection is fine but my Put command fails. There really aren't examples in the help file for these soooo I'm just winging the format.

$FilePutTest01 = _FTP_FilePut($hConn , '"' & @ScriptDir & '\' & $FolderName01 & '.zip'& '"', '/' & $FolderName01 & '.zip' )
$iError = 0
$sMessage = 
$iError = 0
$sMessage = 220 Microsoft FTP Service
331 Anonymous access allowed, send identity (e-mail name) as password.
230 User logged in.
 
$iError = 0
$sMessage = 250 CWD command successful.
 
$iError = 0
$sMessage = 
 
Thanks everyone!

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites

Show a total snippet for the FTP part including how the variables are set.

Also don't think your need to add the " before and after the source filename.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi Jos, Good point and thank you. Yep, it's got to be the EXTREMELY LONG file name... because I did a test.txt and it was fine... hmmm.. I'll post again when I get it figured out. Code below

#include <FTPEx.au3>

Global $FTPiError,$FTPsMessage

Local $sServer = '10.x.x.x'
Local $sUsername = ''
Local $sPass = ''
Local $hOpen = _FTP_Open('MyFTP Control')
_FTP_MSG()

Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
_FTP_MSG()

_FTP_DirSetCurrent (  $hConn, '/Upload/' )
_FTP_MSG()

$FilePutTest01 = _FTP_FilePut($hConn , "test.txt", "test.txt" )
_FTP_MSG()

Func _FTP_MSG()
    _FTP_GetLastResponseInfo($FTPiError,$FTPsMessage)
    ConsoleWrite('$iError = ' & $FTPiError& @CRLF & '$sMessage = ' & $FTPsMessage & @CRLF)
EndFunc

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites

Yepper, it was the way I had the function formatted... that was another 1.5 hours of my life LOL. Thanks Everyone Again!  I love AutoIT and you guys are the BEST!!!

$FilePutTest01 = _FTP_FilePut($hConn , @ScriptDir & '\' & $FolderName01 & '.zip',  $FolderName01 & '.zip' )

Works just fine!


"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
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