Sign in to follow this  
Followers 0
compact21

ftp upload doesn't work

11 posts in this topic

Hi, can anyone tell me what am i doing wrong? i can't get the file uploaded, what do i miss?

#include <FTPEx.au3>
Local $sServer = 'name.server.com'
Local $sUsername = 'username'
Local $sPass = 'password'
Local $location = "/name.server.com/"
Local $filename = "notepad.exe"


Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
$put = _FTP_FilePut($hConn, @WorkingDir&"\"&$filename, $location & $filename)
If $put Then traytip("Uploaded","The file has been uploaded!",15,3)
Local $Ftpc = _FTP_Close($hConn)
Local $Ftpo = _FTP_Close($hOpen)
Sleep(2000)
Exit

Share this post


Link to post
Share on other sites



Where is the script failing? What error checking have you put in place?

I would check for @error after every FTP call, to find out where it is failing for you. Something like this:

Local $hOpen = _FTP_Open('MyFTP Control')
    If @error Then ;<Do something>
    
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
    If @error Then ;<Do something>
    
$put = _FTP_FilePut($hConn, @WorkingDir&"\"&$filename, $location & $filename)
    If @error Then ;<Do something>

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

thanx for your answer, well the error is on _FTP_FilePut() function, how do i fix that?

Share this post


Link to post
Share on other sites

What is it setting @error value to?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

i'm not sure i understood what you mean, this is from the help file: 

Return Value Success: 1. Failure: 0 and sets the @error flag to non-zero.

Share this post


Link to post
Share on other sites

Make sure you are allowed to upload files to the main directory of your website, also make sure your website's ftp allows .exe file upload.

Share this post


Link to post
Share on other sites

The FTP UDF doesn't work for SFTP sites, so if the site you're connecting to uses any type of SSH, you can't use the UDF with it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

thanks for your answers, the thing is it worked just fine until 2 days ago, my pc is clean of viruses, i tryed to uninstall and reinstall autoit and beta, i've added an exception for autoit to my firewall, and still not working i tryed to upload the same file with filezilla and it worked so i don't think is the website...

Share this post


Link to post
Share on other sites

I think it might have been useful to mention that it worked at one time and now doesn't. That's an important point in the troubleshooting process.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Try using to use _ftp_progressupload, which sends small chunks at a time.

I had issues with FTP fileput uploading a large file. It would connect, upload, and disconnect for no appearent reason long before it was finished. I still don't quite understand why, but from what I could gather it is because of routers that try to actively end idle connections, and don't handle FTP connections correctly. Filezilla and windows explorer uploaded the file as expected.

_ftp_fileput worked for me at first, but began to fail when the file grew.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

@DictatoroftheUSA thanks, the problem was solved by reinstaling the OS, still don't know the error reason, anyway it works fine now.

@ BrewManNH, thanks for the tip, it's been noted.

Edited by compact21

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