Jump to content
Sign in to follow this  
PcExpert

FTP.au3 File Overwrite

Recommended Posts

PcExpert

Hi all,

I just read something about an overwrite flag for _FTPPutFile() , but how to activate the overwrite flag?

Thanks!

Share this post


Link to post
Share on other sites
BigDod

Does This answer your question



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites
PcExpert

OK, so it does overwrite it automattically. But why is the file I want to upload empty once its on the ftp server? I did use the dllcall for wininet.dll already.

Share this post


Link to post
Share on other sites
PcExpert

But why are the files empty once on the FTP Server?

Share this post


Link to post
Share on other sites
Jos

Not sure what you expect as an answer here.... my crystal ball isn't functioning today and hate guess work. :)

Maybe:

- tell use what you have done to test/debug..

- show some scriptlet to show what your are doing

- did you test the same thing with an FTP program and did that work ?


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
PcExpert

My Code:

$server = 'ftp.server'

$username = 'usernamehere'

$pass = 'passhere'

$dllhandle = DllOpen( 'wininet.dll' )

If $dllhandle == -1 Then

MsgBox(0, "", "Kan een vereist dll bestand niet vinden.")

EndIf

$Open = _FTPOpen('MyFTP Control')

If $Open = @error Then

MsgBox(0, "", "FOUT bij openen FTP sessie")

EndIf

$Conn = _FTPConnect($Open, $server, $username, $pass)

If $Conn = @error Then

MsgBox(0, "", "FOUT bij het verbinden/inloggen")

EndIf

$Ftpp = _FtpPutFile($Conn, @TempDir & "\request.ini", "/app/License/request.ini")

If $Ftpp = @error Then

MsgBox(0, "", "FOUT bij versturen van bestand")

EndIf

$Ftpc = _FTPClose($Open)

If $Ftpc = @error Then

MsgBox(0, "", "FOUT bij het sluiten van de FTP sessie")

EndIf

FileDelete(@TempDir & "\request.ini")

DllClose($dllhandle)

Msgbox(0, "", "Done! :) ")

Exit

EndFunc

And it does work when the file is being sent by an ftp program.

The only thing I get is 'Done! :P' , so no errors.

Edited by PcExpert

Share this post


Link to post
Share on other sites
PcExpert

This is how its created:

InetGet("http://url.here/request.ini", @TempDir & "\request.ini")

$request = IniRead(@TempDir & "\request.ini", "Global", "requests", "")

$ordernummer = $request + 1

IniWrite(@TempDir & "\request.ini", "Global", "requests", $ordernummer)

IniWrite(@TempDir & "\request.ini", "Order " & $ordernummer, "Naam", GUICtrlRead($naam))

IniWrite(@TempDir & "\request.ini", "Order " & $ordernummer, "Email", GUICtrlRead($email))

IniWrite(@TempDir & "\request.ini", "Order " & $ordernummer, "requested", @MDAY & "-" & @MON & "-" & @YEAR)

If I comment the ftp stuff, so its only edited and saved to my tempdirectory, the file has the iniwrite content.

Edited by PcExpert

Share this post


Link to post
Share on other sites
PcExpert

AnyBody?

Share this post


Link to post
Share on other sites
PcExpert

*bump*

Share this post


Link to post
Share on other sites
Jos

I am surprised to see you just keep bumping this thread without specifying any more info about what else you tried or specifying you checked security and the FTP server log etc etc ...

Try to copy the file before you upload it to ensure its available for upload.

check your FTP server setting and log files to see whats happening .....

etc...

We cannot do it for you and with the limited info given there isn't much we can do for you.

:D

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
GEOSoft

I don't know whats causing your problem but I can tell you that I get exactly the same problem if I don't stop my firewall when I FTP up to my site.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
PcExpert

I tried it with my local FTP server too, but also, no results.

This is the code I use:

#include<[url="ftp://ftp.au3"]FTP.au3[/url]>
$server = 'ftp.server'
$username = 'USERNAME'
$pass = 'PASS'
$dllhandle = DllOpen( 'wininet.dll' )

$passive = 1

$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass, $passive)
$Ftpp = _FtpPutFile($Conn, 'C:\WINDOWS\Notepad.exe', '/Example.exe')
$Ftpc = _FTPClose($Open)
DllClose($dllhandle)

this is the log file from the ftp server:

[5] Sat 19Jan08 16:07:15 - (000044) Connected to 192.168.1.113 (Local address 192.168.1.4)
[5] Sat 19Jan08 16:07:15 - (000044) Closing connection
[5] Sat 19Jan08 16:07:15 - (000045) Connected to 192.168.1.113 (Local address 192.168.1.4)
[5] Sat 19Jan08 16:07:15 - (000045) Closing connection
[5] Sat 19Jan08 16:07:26 - (000046) Connected to 192.168.1.113 (Local address 192.168.1.4)
[5] Sat 19Jan08 16:07:26 - (000046) User USERNAME logged in
[5] Sat 19Jan08 16:07:26 - (000047) Connected to 192.168.1.113 (Local address 192.168.1.4)
[5] Sat 19Jan08 16:07:27 - (000047) User USERNAME logged in
[5] Sat 19Jan08 16:07:28 - (000047) Closing connection for user USERNAME(00:00:02 connected)
[5] Sat 19Jan08 16:17:26 - (000046) Connection timed out
[5] Sat 19Jan08 16:17:28 - (000046) Closing connection for user USERNAME(00:10:02 connected)

What I see in the FTP server log is that its connecting, but then it immediately closes the connection. Why does it act like that? I also tried to set $passive to 0 but that didnt work.

Edited by PcExpert

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
Sign in to follow this  

×