Jump to content

Recommended Posts

Posted

i've writtien a screenshot upload program using Wouters ftp.au3 UDF, but want to check if the file already exists on the ftp site, thus informing the uploader to rename his/her file and try again.

i've tried fileexists and inetget/inetgetsize, but none seems to do it right, can anyone help me?

here's my current source code

#include <GuiConstants.au3>
#include <ftp.au3>
Opt("GUIOnEventMode", 1)
$X = BitOr($WS_POPUP, $WS_BORDER)
if not fileexists(@ProgramFilesDir & "\Guild Wars\GW.exe") Then
    msgbox(48, "Warning!", "Guildwars is not installed on this computer", 5)
    Exit
Else
    EndIf

GuiCreate("ScreenShot uploader", 392, 160,-1, -1 , $X)

GuiCtrlCreateGroup("OoTG Screenshot uploader", 10, 10, 370, 110)

$f1 = GuiCtrlCreateInput("File1", 20, 30, 280, 20)
$file1 = GuiCtrlCreateButton("Browse", 310, 30, 60, 20)
GUICtrlSetOnEvent(-1, "file1")

$f2 = GuiCtrlCreateInput("File2", 20, 60, 280, 20)
$file2 = GuiCtrlCreateButton("Browse", 310, 60, 60, 20)
GUICtrlSetOnEvent(-1, "file2")

$f3 = GuiCtrlCreateInput("File3", 20, 90, 280, 20)
$file3 = GuiCtrlCreateButton("Browse", 310, 90, 60, 20)
GUICtrlSetOnEvent(-1, "file3")

$upload = GuiCtrlCreateButton("Upload", 20, 130, 150, 20)
GUICtrlSetOnEvent(-1, "upload")


$cancel = GuiCtrlCreateButton("Cancel", 220, 130, 150, 20)
GUICtrlSetOnEvent(-1, "Cancel")

GuiSetState()

;functions
func cancel()
    msgbox(64,"Copyright 2006", "written by Rich Easton," & @CR & "rich.easton@gmail.com", 5)
    exit
EndFunc

func upload()
    ProgressOn("Screenshot upload", "please wait...", "open ftp connection")
    sleep(3000)
    $server = ****************'
    $username = '********'
    $pass = '********'
    $Open = _FTPOpen('Ootg screenshot uploader')
    $Conn = _FTPConnect($Open, $server, $username, $pass)
    if GUICtrlRead($f1) = "file1" or "" Then
        ProgressSet(30, "no file to upload", "moving to next file")
        sleep(3000)
        Else
        $len1 = stringlen(GUICtrlRead($f1))
        $Var1 = stringmid(GUICtrlRead($f1), 37, $len1)
            ProgressSet(30, "Uploading " & $var1, "please wait...")
            sleep(3000)
            $Ftpp = _FtpPutFile($Conn, GUICtrlRead($f1), '/screenshots/' & $var1)
    ;EndIf
    EndIf
    if GUICtrlRead($f2) = "file2" or "" Then
        ProgressSet(60, "no file to upload", "moving to next file")
        sleep(3000)
        Else
        $len2 = stringlen(GUICtrlRead($f2))
        $Var2 = stringmid(GUICtrlRead($f2), 37, $len2)
        ProgressSet(60, "Uploading " & $var2, "please wait...")
        sleep(3000)
        $Ftpp = _FtpPutFile($Conn, GUICtrlRead($f2), '/screenshots/' & $var2)
    EndIf
    if GUICtrlRead($f3) = "file3" or "" Then
        ProgressSet(90, "no file to upload", "closing connection")
        sleep(3000)
        Else
        $len3 = stringlen(GUICtrlRead($f3))
        $Var3 = stringmid(GUICtrlRead($f3), 37, $len3)
        ProgressSet(90, "Uploading " & $var3, "Closing Connection")
        sleep(3000)
        $Ftpp = _FtpPutFile($Conn, GUICtrlRead($f3), '/screenshots/' & $var3)
        EndIf
    ProgressSet(100, "Complete", "complete")
    sleep(3000)
    ProgressOff()
    $Ftpc = _FTPClose($Open)
EndFunc 

func file1()
    $fod1 = FileOpenDialog("File1 selector", @ProgramFilesDir & "\Guild Wars\Screens\", "Images (*.jpg;*.bmp)", 1 + 8)
    guictrlsetdata($f1, $fod1, "")
endfunc

func file2()
    $fod2 = FileOpenDialog("File2 selector", @ProgramFilesDir & "\Guild Wars\Screens\", "Images (*.jpg;*.bmp)", 1 + 8)
    guictrlsetdata($f2, $fod2, "")
endfunc

func file3()
    $fod3 = FileOpenDialog("File3 selector", @ProgramFilesDir & "\Guild Wars\Screens\", "Images (*.jpg;*.bmp)", 1 + 8)
    guictrlsetdata($f3, $fod3, "")
endfunc

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
WEnd
Exit

thanks in advance

RichE

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Posted (edited)

i've writtien a screenshot upload program using Wouters ftp.au3 UDF, but want to check if the file already exists on the ftp site, thus informing the uploader to rename his/her file and try again.

i've tried fileexists and inetget/inetgetsize, but none seems to do it right, can anyone help me?

thanks in advance

RichE

you may want to PM wouter on this one... i'm sorry i haven't used that UDF to offer any advice on it, but here's a free bump atleast... Edited by cameronsdad
Posted

thats sad.

i just putted that there so that ppl dont PM me if it deletes all there files accedentily (not that anything like that *should* happen :P)

sorry, goofy mood already today, and i've only finished the first of 3 24 oz energy drinks... Great work like always w0uter.
Posted

here is an beta (its not tested fully but atleast you will see a way how to do what you want :P)

thanks mate your a star, will give you feedback on how it all works :lmao:

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Posted

thats sad.

i just putted that there so that ppl dont PM me if it deletes all there files accedentily (not that anything like that *should* happen :P)

at first i was going to say that my computer caught fire, but i don't want someone with 1 post reading this later and not using it because they think something like that may be possible...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...