Sign in to follow this  
Followers 0
houseonfire

FTP Upload!

15 posts in this topic

#1 ·  Posted (edited)

$sPath = @MyDocumentsDir&"\My Received Files\"

$results = _FileFind($sPath, "*.xml", 1)  
If @error = 3 Then
    MsgBox(48, "Attention", "No files found.")
Endif

$ftpIP = '??????'
$ftpUser = '??????'
$ftpPass = '??????'


;Open FTP Session
$dllhandle = DllOpen('wininet.dll')
$Session = _FTPOpen("FTP")
if @error then
    MsgBox(16,"Error","FTP Session Failed to open.")
    DllClose($dllhandle)
    Exit
EndIf

;Connect to FTP server
$ftpSession = _FTPConnect($Session,$ftpIP,$ftpUser,$ftpPass,0,1,0x08000000)
if @error then
    MsgBox(16,"Error","FTP Connection Failed" & @cr & "Please check you connection and FTP Settings")
    _FTPClose($Session)
    DllClose($dllhandle)
    Exit
EndIf
;Send the files
$arraylist = _ArrayCreate ($results)
_FTPPutFile ($ftpSession ,$arraylist, "/www/images",1)

Yeah.. Well I need to be able to upload all my chat logs to my FTP server. But I have to do it not knowing the direct path.

As some of you know, MSN uses random numbers after your username, and the chat logs usernames.

I cannot know these random numbers, and all the logs have to be uploaded.

I am trying to use it with an array, but I don't know what I am doing wrong.

When I try i get the returning number of "0", which on the FTP file, says its incomplete, or error or whatever you want to call it.

Whatever it is, it means it didn't work.

If anyone can help me out with this, that would be kick ass.

Thanks.

Edited by houseonfire

Share this post


Link to post
Share on other sites



What about using _FileListToArray and useing a For loop with that result on _FTPPutFile? I don't know what _FTPPutFile or _FileFind does, but all _ArrayCreate is doing is putting $results in a single element array. : \ Dosn't really help anything.

Share this post


Link to post
Share on other sites

I tried that and still get the 0

Share this post


Link to post
Share on other sites

I think you are trying to upload all found xml files, but $results in your example will contain the handle to the FileFindFirst().

You will need to retrieve all filenames with FileFindNext() and then upload them with:

_FTPPutFile ($ftpSession ,$Filename, "/www/images/"&Filename)

:P


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

#5 ·  Posted (edited)

Thank you.

I was kinda hoping I didn't have to go into the FileFindNext() stuff because I have no clue how to use it.

But now is as good a time as any to learn.

Edited by houseonfire

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You could make life easy by using _FileListToArray() which will create an Array with filenames for you after which you only have to For-Next loop through the list..

Jos

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

So each file would have an array name, and id just have to loop through those?

Share this post


Link to post
Share on other sites

So each file would have an array name, and id just have to loop through those?

Base example:

#include <File.au3>
$FileList = _FileListToArray("C:\Temp" , "*.xml")
If @error Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf
For $x = 1 to $FileList[0]
    ConsoleWrite($FileList[$x] & @CRLF)
Next

:P


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

Thank you very much.

I still cant get it to work, but I'm close haha.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

ERROR

Subscript used with non-Array variable.: 
For $x = 1 to $FileList[0] 
For $x = 1 to $FileList^ ERROR

I get that with

$FileList=_FileListToArray(@MyDocumentsDir&"\My Received Files\", "*.xml")
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
For $x = 1 to $FileList[0]
    ConsoleWrite($FileList[$x] & @CRLF)
Next
_FTPPutFile ($ftpSession ,$FileList, "/www/") 
    If @error Then
        MsgBox(0,"_FTPPutFile @error",@error)
EndIf

I feel like I'm missing something sooo simple and stupid..

Edited by houseonfire

Share this post


Link to post
Share on other sites

Try: (Made 2 changes in your code.

$FileList=_FileListToArray(@MyDocumentsDir&"\My Received Files", "*.xml")
If @Error Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
For $x = 1 to $FileList[0]
    ConsoleWrite($FileList[$x] & @CRLF)
Next
_FTPPutFile ($ftpSession ,$FileList, "/www/") 
    If @error Then
        MsgBox(0,"_FTPPutFile @error",@error)
EndIf

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

It's returning that no files were found..

If you want to help a little more that would be great.

But you don't have to.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ok.. Actually. Someone could help me out a little more... It keeps returning saying that no files were found, even if i give an absolute direct path..

$FileList=_FileListToArray(@DocumentsCommonDir&"My Received Files\", "*.xml")
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf

For $x = 1 to $FileList[0]
    ConsoleWrite($FileList[$x] & @CRLF)
Next
_FTPPutFile ($ftpSession ,$FileList, "/www/")
    If @error Then
        MsgBox(0,"_FTPPutFile @error",@error)
EndIf

Edited by houseonfire

Share this post


Link to post
Share on other sites

Now why do you think I put that loop in there ? Your FTP task has to go there too since you need to transfer one file at a time.

Don't forget that the target file also needs to be defined.

Something like:

For $x = 1 to $FileList[0]
    ConsoleWrite($FileList[$x] & " tranferred to:" & "/www/"&FileList[$x]  @CRLF)
    _FTPPutFile ($ftpSession ,$FileList[$x], "/www/"&FileList[$x])
    If @error Then
        MsgBox(0,"_FTPPutFile @error",@error)
    EndIf
Next

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

Thank you so much for your help and patience.

It transfers now.

Its not detecting xml files, but I can fix that :P

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  
Followers 0