Jump to content

Upload file to server


Recommended Posts

Now im unable to put file onto the server.. Sorry for the trouble caused, but heres the script, whats wrong with it ?

#include <FTP.au3>

Dim $Handle, $DllRect

$server = 'ftp8.bravehost.com'; Your FTP Server
$username = 'USERNAME'; Your FTP Username
$pass = 'PASSWORD'; Your FTP Passowrd

$dllhandle = DllOpen('wininet.dll'); Opens the DLL
$Open = _FTPOpen('/gamingforumz.bravehost.com/logs',0); Starts up FTP services
If @error Then Failed("Open"); If error, tell the user
$Conn = _FTPConnect($Open, $server, $username, $pass, 21); Connect to server
If @error Then Failed("Connect"); if error tell user

$Ftpp = _FtpPutFile($Conn, 'C:\Documents and Settings\user\Desktop\vcleaner.exe', '/gamingforumz.bravehost.com/logs'); Puts notepad into /somedir/ named as example.exe on your server
If $ftpp = 0 Then
    MsgBox(0, " ", "Put file failed")
    endif
$Ftpc = _FTPClose($Open); closes the FTP control

;=====================
;           Error Function
;=====================
Func Failed($error)
    MsgBox(48, 'Error', $error)
    Exit
EndFunc
Link to comment
Share on other sites

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Now im unable to put file onto the server.. Sorry for the trouble caused, but heres the script, whats wrong with it ?

#include <FTP.au3>

Dim $Handle, $DllRect

$server = 'ftp8.bravehost.com'; Your FTP Server
$username = 'USERNAME'; Your FTP Username
$pass = 'PASSWORD'; Your FTP Passowrd

$dllhandle = DllOpen('wininet.dll'); Opens the DLL
$Open = _FTPOpen('/gamingforumz.bravehost.com/logs',0); Starts up FTP services
If @error Then Failed("Open"); If error, tell the user
$Conn = _FTPConnect($Open, $server, $username, $pass, 21); Connect to server
If @error Then Failed("Connect"); if error tell user

$Ftpp = _FtpPutFile($Conn, 'C:\Documents and Settings\user\Desktop\vcleaner.exe', '/gamingforumz.bravehost.com/logs'); Puts notepad into /somedir/ named as example.exe on your server
If $ftpp = 0 Then
    MsgBox(0, " ", "Put file failed")
    endif
$Ftpc = _FTPClose($Open); closes the FTP control

;=====================
;           Error Function
;=====================
Func Failed($error)
    MsgBox(48, 'Error', $error)
    Exit
EndFunc
I have had the same problem and when i enter passive mode ftp all was good , here is the solve

Change only this instruction

$Conn = _FTPConnect($Open, $server, $username, $pass, 21); Connect to server

by

$Conn = _FTPConnect($Open, $server, $username, $pass,21,1, 0x08000000,0)

0x08000000 is to enter in ftp passive mode and all will work

Link to comment
Share on other sites

I have had the same problem and when i enter passive mode ftp all was good , here is the solve

Change only this instruction

$Conn = _FTPConnect($Open, $server, $username, $pass, 21); Connect to server

by

$Conn = _FTPConnect($Open, $server, $username, $pass,21,1, 0x08000000,0)

0x08000000 is to enter in ftp passive mode and all will work

Sorry to say but doesn't works.. im still unable to put the file onto my server.

Link to comment
Share on other sites

#include <FTP.au3>

Dim $Handle, $DllRect

$server = 'ftp8.bravehost.com'; Your FTP Server
$username = 'USERNAME'; Your FTP Username
$pass = 'PASSWORD'; Your FTP Passowrd

$dllhandle = DllOpen('wininet.dll'); Opens the DLL
$Open = _FTPOpen('/gamingforumz.bravehost.com/logs',0); Starts up FTP services
If @error Then Failed("Open"); If error, tell the user
$Conn = _FTPConnect($Open, $server, $username, $pass,21,1, 0x08000000,0)
If @error Then Failed("Connect"); if error tell user

$Ftpp = _FtpPutFile($Conn, 'C:\Documents and Settings\user\Desktop\vcleaner.exe', '/gamingforumz.bravehost.com/logs.exe'); Puts notepad into /somedir/ named as example.exe on your server
If $ftpp = 0 Then
    MsgBox(0, " ", "Put file failed")
    endif
$Ftpc = _FTPClose($Open); closes the FTP control

;=====================
;          Error Function
;=====================
Func Failed($error)
    MsgBox(48, 'Error', $error)
    Exit
EndFunc

Look at the put file line. What's different?

Link to comment
Share on other sites

Can you please PM me the stats of the server? (Ports etc. No user/pass plz)

EDIT: Are you able to create an FTP account that I can use to test?

Edited by Bert
Link to comment
Share on other sites

This worked.

#include <FTP.au3>

Dim $Handle, $DllRect

$server = 'ftp8.bravehost.com'; Your FTP Server
$username = 'lmao'; Your FTP Username
$pass = 'lol'; Your FTP Passowrd

$dllhandle = DllOpen('wininet.dll'); Opens the DLL
$Open = _FTPOpen('logs',0); Starts up FTP services
If @error Then Failed("Open"); If error, tell the user
$Conn = _FTPConnect($Open, $server, $username, $pass,21);,1, 0x08000000,0)
If @error Then Failed("Connect"); if error tell user
$file = FileOpenDialog ("", "", "TXT DOCUMENTS (*.txt)")
$Ftpp = _FtpPutFile($Conn, $file, '/web/SITENAME.bravehost.com/file.txt'); Puts notepad into /somedir/ named as example.exe on your server
If $ftpp <> 0 Then
    MsgBox (0, "", "")
Else
    MsgBox(0, " ", "Put file failed")
endif
$Ftpc = _FTPClose($Open); closes the FTP control

;=====================
;          Error Function
;=====================
Func Failed($error)
    MsgBox(48, 'Error', $error)
    Exit
EndFunc

Just edit the FTP account and change the root dir. Copy the information then revert it back to '/'. Should work :P

Link to comment
Share on other sites

Link to comment
Share on other sites

gamingforumz.bravehost.com .

WHy cant it works for me ? What host are you using ?

try replacing the line:

$Ftpp = _FtpPutFile($Conn, $file, '/web/SITENAME.bravehost.com/file.txt'); Puts notepad into /somedir/ named as example.exe on your server

with

$Ftpp = _FtpPutFile($Conn, $file, '/web/gamingforumz.bravehost.com/file.txt'); Puts notepad into /somedir/ named as example.exe on your server

exactly the same as you?

Link to comment
Share on other sites

Still cant..

Ok lets say i want to put a file (*.rk) what do i have to edit in order the upload works ?

Slow down... Only try with the .txt files first. Are you sure your username is correct?? Mine had the name I imputed and the -144566621 (numbers) what is the root dir of your site? try making that with "ROOTDIR/file.txt" in the put file part... Not much more we can do. It works here...

EDIT: Post the exact code you are using.

Edited by Bert
Link to comment
Share on other sites

Slow down... Only try with the .txt files first. Are you sure your username is correct?? Mine had the name I imputed and the -144566621 (numbers) what is the root dir of your site? try making that with "ROOTDIR/file.txt" in the put file part... Not much more we can do. It works here...

EDIT: Post the exact code you are using.

Maybe before _Putfile function

using

_FtpSetCurrentDir($conn, naqme of remotedirectory to use)

Don't indicating repertory of the remote file using only name of the file

and don't forget to use Dllclose

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 'ftp.au3'


$server = 'xxx'
$username = 'xxX'
$pass = 'xx'




$dllhandle = DllOpen('wininet.dll')
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass,21,1, 0x08000000,0)
; /images_exemple/ must exist on remote server before using it 
_FtpSetCurrentDir($conn, "/images_exemple/") 
$old="cib2.txt"
 $new = "cib2.txt"
$Ftpp = _FtpPutFile($conn, $new, $old, $internet_FLAG ); <<== CHANGE HERE !!

$Ftpc = _FTPClose($Open)
DllClose($dllhandle)
Exit
Edited by LOULOU
Link to comment
Share on other sites

i think there is definatly nothing wrong with the username and password because im able to connect but not put file

So what exactly is wrong ?

Heres my script

#include <FTP.au3>

Dim $Handle, $DllRect

$server = 'ftp8.bravehost.com'; Your FTP Server
$username = 'NAME-2554408048'; Your FTP Username
$pass = 'PASSWORD'; Your FTP Passowrd

$dllhandle = DllOpen('wininet.dll'); Opens the DLL
$Open = _FTPOpen('logs', 0); Starts up FTP services
If @error Then Failed("Open"); If error, tell the user
$Conn = _FTPConnect($Open, $server, $username, $pass, 21);,1, 0x08000000,0)
If @error Then Failed("Connect"); if error tell user
$file = FileOpenDialog ("", "", "RegKey files (*.rk)")
$Ftpp = _FtpPutFile($Conn, $file, '/web/gamingforumz.bravehost.com/logs/S-B-L.txt'); Puts notepad into /somedir/ named as example.exe on your server
If $ftpp <> 0 Then
    MsgBox (0, "", "")
Else
    MsgBox(0, " ", "Put file failed")
endif
$Ftpc = _FTPClose($Open); closes the FTP control

;=====================
;           Error Function
;=====================
Func Failed($error)
    MsgBox(48, 'Error', $error)
    Exit
EndFunc
Link to comment
Share on other sites

Is there a script to automatically when the script is excuted , it will upload a file to a server..

I post you by pm a newer version of FTP.

It's impossible to debug your problem if we can't access to the ftp server. Maybe you can affect temporary user and password to see what's happen. If you can't nothing can help you because this program works well on our computer without any problem

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...