Jump to content

Need help with _FtpPutFile


 Share

Recommended Posts

I'm new to Autoit,and I have some problems with FtpPutFile.

What I'm trying to do is to put an image called 'VR.jpg' when a

value is within a range of numbers.Then it grabs an image from

a dir and sends it via ftp to a server.

I got it to work to the point when it shall put the file via ftp.

Can somebody help me.

Here is my code so far:

Const $INTERNET_FLAG_PASSIVE = 0x08000000
Const $INTERNET_FLAG_TRANSFER_ASCII = 0x00000001
Const $INTERNET_FLAG_TRANSFER_BINARY = 0x00000002
Const $INTERNET_DEFAULT_FTP_PORT = 21
Const $INTERNET_SERVICE_FTP = 1
Const $INTERNET_FLAG_NO_CACHE_WRITE = 0x4000000
Const $internet_FLAG = $INTERNET_FLAG_TRANSFER_BINARY + $INTERNET_FLAG_NO_CACHE_WRITE
#include <File.au3>
#include <array.au3> ; Denne er for å vise arrayet _ArrayDisplay()
#include <FTP.au3>

$in_filnavn = "veret.txt"

Dim $Linjer
Global $VRmappe
Global $VRfil


_FileReadToArray($in_filnavn, $Linjer)

$midlertidig = StringSplit($Linjer[1], " ") ; Funnet Rad Nummer

Dim $array [$Linjer[0] ][ $midlertidig[0]]

For $antall = 1 To $Linjer[0]
    $midlertidig = StringSplit($Linjer[$antall], " ")
    If $midlertidig[0] = 1 Then ContinueLoop
        For $j = 1 To $midlertidig[0]
            $array[$antall-1] [$j-1] = $midlertidig[$j]
        Next
    Next
    $Resultatet = Int($array[39][1]);Leser rad 39 kolonne 2 som er vindretningen
    ;_ArrayDisplay($array)
    
    Switch $Resultatet 
    Case  348 to 360
        $VRmappe = '/VR/N/'
        _LoginServer()
    Case  0 to 11
        $VRmappe = '/VR/N/';Nord
        _LoginServer()
    Case  12 to 33
        $VRmappe = '/VR/NNE/';Nord-Nordøst
        _LoginServer()
    Case  34 to 56
        $VRmappe = '/VR/NE/';Nordøst
        _LoginServer()
    Case  57 to 78
        $VRmappe = '/VR/ENE/';Øst-nordøst
        _LoginServer()      
    Case  79 to 101
        $VRmappe = '/VR/E/';Øst
        _LoginServer()      
    Case  102 to 123
        $VRmappe = '/VR/ESE/';Øst-sørøst
        _LoginServer()
    Case  124 to 146
        $VRmappe = '/VR/SE/';Sørøst
        _LoginServer()
    Case  147 to 168
        $VRmappe = '/VR/SEE/';Sør-sørøst
        _LoginServer()
    Case  169 to 190
        $VRmappe = '/VR/S/';Sør
        _LoginServer()
    Case  191 to 213
        $VRmappe = '/VR/SSV/';Sør-sørvest
        
        _LoginServer()
    Case  214 to 236
        $VRmappe = '/VR/SV/';Sørvest
        _LoginServer()
    Case  237 to 257
        $VRmappe = '/VR/VSV/';Vest-sørvest
        _LoginServer()      
    Case  258 to 281
        $VRmappe = '/VR/V/';Vest
        _LoginServer()
        ; Linjene under er bare for å teste output.
        ;MsgBox(0,"Vindretning","Vestlig")
        ;MsgBox(0,"Vindretning",$array[39][1])
        ;Ferdig vinden kommer fra vest
    Case  282 to 303
        $VRmappe = '/VR/VNV/';Vest-nordvest
        _LoginServer()  
    Case  304 to 326
        $VRmappe = '/VR/NV/';Nordvest
        _LoginServer()
    Case  327 to 347
        $VRmappe = '/VR/NNV/';Nord-Nordvest
        _LoginServer()      
    EndSwitch
Func _LoginServer()
        $server = '************'
        $username = '********'
        $pass = '*********'
        $uploaddir = '/Vtest/';Mappen på serveren
        $dllhandle = DllOpen('wininet.dll')
        $VRfil = 'VR.jpg'
        $Newfile = $VRmappe & $VRfil
        $Oldfile = $uploaddir & $VRfil

        $Open = _FTPOpen('ftp')
         if @error then
              msgbox(0,"","fail_open")
         endif
        $Conn = _FTPConnect($Open, $server, $username, $pass,21,1, 0x08000000,0)
         if @error then
              msgbox(0,"","fail_connect")
         endif
        $Ftpp = _FtpPutFile($Conn,$Newfil,$Oldfil,$internet_FLAG ); VR = vind retning
        if @error then
              msgbox(0,"","fail_putfile")
         endif
        $Ftpc = _FTPClose($Open)
        DllClose($dllhandle)
EndFunc

thanks ocamax

Link to comment
Share on other sites

Is there nobody who can give me a tips why the above code won't work?

Everything is ok until the point where I shall put the file on the remote server.

Ocamax

Sorry about that my last post repeated 3 times, I got internal server error when I should

post and tried 3 times to send the post ;)

Ocamax

Link to comment
Share on other sites

  • Moderators

Sorry about that my last post repeated 3 times, I got internal server error when I should

post and tried 3 times to send the post ;)

Ocamax

I deleted two of them... server has been wacky for a week or so now.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

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