Jump to content
Sign in to follow this  
egalvez

Problem with _FtpPutFile uploads

Recommended Posts

I wrote an AutoIt3 program which, among other things, automatically uploads audio sermon files to a web site for a friend. It uploads four files: a .RAM file, a .RM file, an HTML web page, and a sermon outline in PDF format. When my friend used the program recently for several sermons, it uploaded all files fine, except the .RM files, which are by far the biggest of the four files, with each .RM file being several megabytes. He did about a dozen sermons and in every case, all files but the .RM files uploaded fine. But every time I test the program, I have no problems at all with the .RM files uploading. I'm using Verizon DSL, he's using Comcast cable, i.e., he has even faster access than I do. I don't know what could be causing his uploading of .RM files to fail. The _FtpPutFile code I got from these forums works great, but I don't necessarily know what I'm doing with it. How can I best check to see if the file uploaded or not? Currently, he gets no message saying the upload did not work, but I thought that was accounted for in the following code. With private info replaced by generic terms, here's what I have for the uploading of the .RM file:

$nRetCode = _FtpPutFile("ip_address", _
                        "username", _
                        "password", _
                        $regRmPath & "\" & StringLeft($fileNameString, 8) & ".rm", _
                        "public_html/audio_sermons/" & StringLeft($fileNameString, 8) & ".rm", _
                        $FTP_TRANSFER_TYPE_BINARY)
                        if $nRetCode <> -1 Then
                            msgbox(4112,"Sermon Update Assistant","Upload of RM file was NOT successful")
                        Else
                            msgbox(4160,"Sermon Update Assistant","Upload of RM file WAS successful")
                        EndIf

So, I'm really wondering two things: 1) what could be preventing him from uploading the .RM files, keeping in mind that the other files upload with no problem, and 2) how can I do a test to see if the uploaded file exists on the web server? Is there an internet-related equivalent of the FileExists function, something that would allow me to test for the existence of a file over the internet?

Edited by egalvez

Share this post


Link to post
Share on other sites

your filename is formatted interestingly

StringLeft($fileNameString,8) & ".rm"

What are the contents of $fileNameString ? You are hard-coding to take the first 8 characters and adding .rm to it does that file actually exist?

Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

Hi. Yes, the file exists because my GUI requires that the user specify a .RM file which must exist on the PC in MM-DD-YY.RM format. If the check fails, the user is told he can't proceed. So the file exists, and I have had no problems when testing the program myself. $fileNameString is the MM-DD-YY part, as in 03-28-05.

Share this post


Link to post
Share on other sites

Never used _FtpPutFile() Does it have an option for Active / Passive transfer? He might be behind a firewall.


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

Where is this _FtpPutFile() function?

<{POST_SNAPBACK}>

I found the _FtpPutFile() in two posts, here and here

Never used _FtpPutFile() Does it have an option for Active / Passive transfer?  He might be behind a firewall.

<{POST_SNAPBACK}>

The _FtpPutFile() function does have the following two declarations. Would these be referring to active and passive transfers? I don't know how to use these variables:

Global $INTERNET_FLAG_ASYNC = 0x10000000
Global $INTERNET_FLAG_PASSIVE = 0x08000000

To be honest, though I've used FTP programs for years, I don't even know what active and passive transfers are. My friend, who works for Merck and uses a company laptop, may very well indeed be behind a firewall. The uploading of the small .PDF, .RAM, and .SHTML files works for him fine, it's only the large .RM files that don't upload. Could a firewall be responsible for this?

Share this post


Link to post
Share on other sites

I found the _FtpPutFile() in two posts, here and here

The _FtpPutFile() function does have the following two declarations.  Would these be referring to active and passive transfers?  I don't know how to use these variables:

Global $INTERNET_FLAG_ASYNC = 0x10000000
Global $INTERNET_FLAG_PASSIVE = 0x08000000

To be honest, though I've used FTP programs for years, I don't even know what active and passive transfers are.  My friend, who works for Merck and uses a company laptop, may very well indeed be behind a firewall.  The uploading of the small .PDF, .RAM, and .SHTML files works for him fine, it's only the large .RM files that don't upload.  Could a firewall be responsible for this?

<{POST_SNAPBACK}>

The PASSIVE param is default and optional so if you want to turn it off, call the function as follows:

$nRetCode = _FtpPutFile("ip_address", _
                        "username", _
                        "password", _
                        $regRmPath & "\" & StringLeft($fileNameString, 8) & ".rm", _
                        "public_html/audio_sermons/" & StringLeft($fileNameString, 8) & ".rm", _
                        $FTP_TRANSFER_TYPE_BINARY, 0)

Notice the extra zero value after $FTP_TRANSFER_TYPE_BINARY

You can also look up the return code here

Look here for a definitive explanation on Active FTP vs Passive FTP.

Edited by SumTingWong

Share this post


Link to post
Share on other sites

Thank you for the info, SumTingWong. I've now specified that the FTP upload of the .RM file should be in active mode, but left the other files (.RAM, .SHTML, & .PDF) in passive mode. Now, when I test the program, as soon as it comes time for the .RM file to upload, I get a Windows security alert (see below).

Posted Image

As you can see, the message says "some features" have been blocked. I don't know what features that refers to because when I ignore the alert dialog, the upload of the .RM file proceeds without a hitch. In any event, I'll be alerting my friend that he may need to tell his security software (he has very intense security software on his laptop) to allow my program to do whatever it wants to. Back when the upload of the .RM file was programmed in passive mode, he received no alerts of any kind--the upload just never worked for the .RM file, while the .RAM, .SHTML, and .PDF files uploaded with no problem.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...