Sign in to follow this  
Followers 0
AzKay

FTP funtion not working?

14 posts in this topic

#include <GUIConstants.au3>
#include <FTP.au3>
Opt("GUIOnEventMode", 1)
### Koda GUI section start ###
$News = GUICreate("News", 474, 254, 192, 118)
$NewsBody = GUICtrlCreateEdit("", 0, 0, 473, 217, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Upload = GUICtrlCreateButton("Upload", 0, 224, 161, 25, 0)
GUICtrlSetOnEvent(-1, "UploadClick")
$UploadProgress = GUICtrlCreateProgress(168, 224, 297, 25)
GUISetState(@SW_SHOW)
### Koda GUI section end   ###
$server = "php0h.com"
$username = "user"
$pass = "pass"
$Dir = "/www/"

While 1
    Sleep(100)
WEnd

Func UploadClick()
$ReadNews = GUICtrlRead($NewsBody)
FileOpen("News.txt", 2)
FileWrite("News.txt", $ReadNews)
FileClose("News.txt")
$Size = FileGetSize("News.txt")
    $Open = _FTPOpen("MyFTP Control")
    $Conn = _FTPConnect($Open, $server, $username, $pass)
    $Ftpp = _FtpPutFile($Conn, $News, $Dir)
    $Ftpc = _FTPClose($Open)
MsgBox(0, "", "Done")
EndFunc

It doesnt want to upload... And, how would I get the progress bar working here?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It doesnt want to upload... And, how would I get the progress bar working here?

Did you put checks for the @error code retuned by the FTP commands in your script so you know whats failing?

Two issues in this line:

$Ftpp = _FtpPutFile($Conn, $News, $Dir)

$news = the Handle of a GUI control

$dir doesn't contain a filename ...think thats needed ...

EDIT: this is wrong too, leave it to you to sort out why:

FileOpen("News.txt", 2)

FileWrite("News.txt", $ReadNews)

FileClose("News.txt")

Edited by JdeB

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

Hmm, by the way, is there a help file for the ftp functions? I didnt seem to find it in the thread.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

I added in the @error after ftpputfile, changed the dir to /www/News.txt changed the file to "News.txt", Dont know what you mean with the File() functions. But it still isnt working.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Read the helpfile on the file functions.

Also no there is no 'helpfile' or documentation what so ever for the ftp functions (Ill put it on my big TODO list, right after "failing the schoolyear")

It would help if you posted your new code and tell us the values @error has.


My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <FTP.au3>
Opt("GUIOnEventMode", 1)
### Koda GUI section start ###
$News = GUICreate("News", 474, 254, 192, 118)
$NewsBody = GUICtrlCreateEdit("", 0, 0, 473, 217, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Upload = GUICtrlCreateButton("Upload", 0, 224, 161, 25, 0)
GUICtrlSetOnEvent(-1, "UploadClick")
$UploadProgress = GUICtrlCreateProgress(168, 224, 297, 25)
GUISetState(@SW_SHOW)
### Koda GUI section end   ###
$server = "php0h.com"
$username = "user"
$pass = "pass"

While 1
    Sleep(100)
WEnd

Func UploadClick()
$ReadNews = GUICtrlRead($NewsBody)
FileOpen("News.txt", 2)
FileWrite("News.txt", $ReadNews)
FileClose("News.txt")
    $Open = _FTPOpen("MyFTP Control")
    $Conn = _FTPConnect($Open, $server, $username, $pass)
    $Ftpp = _FtpPutFile($Conn, "News.txt", "/www/News.txt")
        If @error Then MsgBox(0, "FtpPutFile", @error)
    $Ftpc = _FTPClose($Open)
MsgBox(0, "", "Done")
EndFunc

It returns -1


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

All the others were clean, no errors

EDIT::

@scriptdir & "\News.txt" Didnt make any difference.

Edited by AzKay

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Doesnt seem to work either.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

check to content? to you mean, the? Yes I did, for some reason, now, its not writing the file, it was the 1st time I tryed...


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

check to content? to you mean, the? Yes I did, for some reason, now, its not writing the file, it was the 1st time I tryed...

yes meant the..

Why do you think i mentioned the FileOpen/FileWrite/FileClose issue ?

Try to read the helpfile and understand what it is telling you !

$H_file = FileOpen("News.txt", 2)
FileWrite($H_file, $ReadNews)
FileClose($H_file)oÝ÷ ÚÚºÚ"µÍ[Q[]J  ][ÝÓ]ÜË ][ÝÊB[UÜ]J   ][ÝÓ]ÜË ][ÝË  ÌÍÔXY]ÜÊ
Edited by JdeB

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

#14 ·  Posted (edited)

Oke, now it writes, but doesnt upload still. Maybe its the ftp host thats dodgy?

EDIT::

Isnt the host.

Edited by AzKay

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

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