dbTalk Databases Forums  

FTP Upload Download

comp.databases.ms-access comp.databases.ms-access


Discuss FTP Upload Download in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lou O
 
Posts: n/a

Default FTP Upload Download - 01-12-2010 , 10:12 AM






I downloaded InetTransferLib.mda add in by Dev Ashish. I want to use
it with Access 2007 but could not load the library using add in
manager. The file was not listed as an available add in. I opened a
module to add a reference to the lib under tools/references but this
also did not work. Next I opened the mda file in A07 and saved the
file as accde. I was then able to set a reference to it in the VBA
under tools/references.
However when I run the FTPUpload event, the UploadFileToFTPServer
subroutine produces the following error "-2147219289, 200 Type not
set to i". (I haven't tried downloading yet.)
Has anyone used InetTransferLib successfully with Access 2007 and
maybe have some idea what might be going wrong to cause the above
error?
Thanks
Lou

Reply With Quote
  #2  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: FTP Upload Download - 01-12-2010 , 10:57 AM






Don't try an use the mda as an add-in.

Simply open up your 2007 applications, and use the external data tab, click
on ms-access and IMPORT the code modules from that mda.

Once you do the above, then the library should work just fine in 2007...


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal (AT) msn (DOT) com

Reply With Quote
  #3  
Old   
Lou O
 
Posts: n/a

Default Re: FTP Upload Download - 01-12-2010 , 01:44 PM



On Jan 12, 11:57*am, "Albert D. Kallal"
<PleaseNOOOsPAMmkal... (AT) msn (DOT) com> wrote:
Quote:
Don't try an use the mda as an add-in.

Simply open up your 2007 applications, and use the external data tab, click
on ms-access and IMPORT the code modules from that mda.

Once you do the above, then the library should work just fine in 2007...

--
Albert D. Kallal * *(Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKal... (AT) msn (DOT) com
Thanks Albert,
I did as you suggested. However the error persists.
Not sure if you're familiar with the library code but it fails on this
line...

lngRet = apiFTPPutFile(hSession, mstrSrcFile, mstrDestination, _
INTERNET_FLAG_TRANSFER_BINARY Or INTERNET_FLAG_NO_CACHE_WRITE,
0&)

If lngRet = 0 Then Err.Raise conERR_COULD_NOT_TRANSFER_FILE

I'm sure I'll get it working if I keep playing with it.
Any thoughts on what to look for?

Reply With Quote
  #4  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: FTP Upload Download - 01-12-2010 , 03:50 PM



"Lou O" <lgeastwood (AT) gmail (DOT) com> wrote


Quote:
Thanks Albert,
I did as you suggested. However the error persists.
Not sure if you're familiar with the library code but it fails on this
line...

lngRet = apiFTPPutFile(hSession, mstrSrcFile, mstrDestination, _
INTERNET_FLAG_TRANSFER_BINARY Or INTERNET_FLAG_NO_CACHE_WRITE,
0&)

If lngRet = 0 Then Err.Raise conERR_COULD_NOT_TRANSFER_FILE

I'm sure I'll get it working if I keep playing with it.
Any thoughts on what to look for?

=======

Hum, a quick import of the code, and then compiling shows the code does
compile.

A quick test..and it works for me.

here is the code I used:


Dim f As New FTP


f.FtpURL = "ftp://www.mywebsite.com"
f.SourceFile = "c:\abc.txt"
f.DestinationFile = "/wwwroot/test/abc.txt"
f.ConnectToFTPHost "my user name", "my pass word"
f.UploadFileToFTPServer

I would strongly suggest that you open up a ftp session and browse around
the ftp site to ensure you get the "target" destination correct. Just
double click on my computer, and then in the address bar type in the ftp
site name. then use file->login as from the menu.

Often, the root dir is www, or wwwroot, or whatever, and it varies a lot by
providers and how the web site directory structure is setup..

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal (AT) msn (DOT) com

Reply With Quote
  #5  
Old   
Lou O
 
Posts: n/a

Default Re: FTP Upload Download - 01-13-2010 , 03:34 PM



Quote:
* *Dim f * * * As New FTP

* *f.FtpURL = "ftp://www.mywebsite.com"
* *f.SourceFile = "c:\abc.txt"
* *f.DestinationFile = "/wwwroot/test/abc.txt"
* *f.ConnectToFTPHost "my user name", "my pass word"
* *f.UploadFileToFTPServer

I would strongly suggest that you open up a ftp session and browse around
the ftp site to ensure you get the "target" destination correct. *Just
double click on my computer, and then in the address bar type in the ftp
site name. then use file->login as from the menu.

Often, the root dir is www, or wwwroot, or whatever, and it varies a lot by
providers and how the web site directory structure is setup..

--
Albert D. Kallal * *(Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKal... (AT) msn (DOT) com
I opened a ftp session and browsed around the site.
I've carefully checked the destination folder and everything seems to
be fine.
I can copy and paste files into it with explorer no problem.
The sub ConnectToFTPHost lets me connect to the server with my user
name & password.
But the code still stalls every time in sub upLoadFileToFTPServer.
It hangs for about 30 seconds at the same line of code.

lngRet = apiFTPPutFile(hSession, mstrSrcFile, mstrDestination, _
INTERNET_FLAG_TRANSFER_BINARY Or INTERNET_FLAG_NO_CACHE_WRITE,
0&)

Then lngRet returns 0 and raises the error

My site host seems to think the problem relates to firewall or port
settings
He also suggested to check out the Passive/Active connection setting
within the code.
I see INTERNET_FLAG_PASSIVE constant but I'm not sure how or where to
switch it if indeed that would help.
I hope you can shed some more light on this for me.
Thanks

Reply With Quote
  #6  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: FTP Upload Download - 01-14-2010 , 11:16 AM



Perhaps you try http in place of ftp?

For example, the following code works for me:

Sub downtest()


Dim f As New HTTP


f.HttpURL = "http://www.mvps.org/access/downloads/InetTransferLib.zip"
f.DestinationFile = "c:\InetTransferLib.zip"
f.ConnectToHTTPHost
f.WriteHTTPDataToFile

End Sub


Make sure the above code compiles first. I just pasted the above into a
module,
and it works fine for me...

Using http means you have to have a valid hyperlink on the web site, and
don't have to supply any logon information...


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal (AT) msn (DOT) com

Reply With Quote
  #7  
Old   
Lou O
 
Posts: n/a

Default Re: FTP Upload Download - 01-14-2010 , 02:12 PM



On Jan 14, 12:16*pm, "Albert D. Kallal"
<PleaseNOOOsPAMmkal... (AT) msn (DOT) com> wrote:
Quote:
Perhaps you try http in place of ftp?

For example, the following code works for me:

Sub downtest()

* *Dim f * * * As New HTTP

* *f.HttpURL = "http://www.mvps.org/access/downloads/InetTransferLib.zip"
* *f.DestinationFile = "c:\InetTransferLib.zip"
* *f.ConnectToHTTPHost
* *f.WriteHTTPDataToFile

End Sub

Make sure the above code compiles first. I just pasted the above into a
module,
and it works fine for me...

Using http means you have to have a valid hyperlink on the web site, and
don't have to supply any logon information...

--
Albert D. Kallal * *(Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKal... (AT) msn (DOT) com
Albert,
Working with ftp and http is new territory for me and I'm probably
missing some important basics.
I just need a little more help though to resolve my current issue. I
think I'm 95% there.
Thanks for your patience and for sticking with me on this.

Pasting the above code "as is" allowed me to download
InetTransferLib.zip however inserting my URL with http:// prefix still
produced the error URL not found. Apparently it's a ftp site.
I have access to a ftp site as well as a http site.
I could probably download from the http site if I could upload to it.
However my version of InetTransferLib did not include http upload
capabilities.
Or am I missing something obvious?

Reply With Quote
  #8  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: FTP Upload Download - 01-15-2010 , 11:47 AM



"Lou O" <lgeastwood (AT) gmail (DOT) com> wrote


Quote:
Pasting the above code "as is" allowed me to download
InetTransferLib.zip
Great, the above is likely 99% of the goal here. It means
you have imported the library correctly, and now have it
works.

Quote:
however inserting my URL with http:// prefix still
produced the error URL not found. Apparently it's a ftp site.


Right, if you read careful, in my post I stated that if you use http:// then
a VALID web link MUST be available. In other words, you not using ftp
anymore, but you using the web server (web servers and ftp servers are
separate things and separate services). A good deal of web sites expose
files as a link in an web browser. When you do so, it is the web server
(https) that grabbing the file from the web server computer and doing the
download. This is an different process then that of using ftp. This approach
is often preferred as then you can allow people to download files, but NOT
give them access to files sitting on the actual web server (they have to use
the web browser). As mentioned, this approach will ONLY work if you have a
VALID web link that you can/could/would click on to download the file.

so, in the above code example, I used:

http://www.mvps.org/access/downloads...ransferLib.zip

If you click on the above, you see that a download starts. And, that
download is not ftp, but http and will thus requite a valid web link.
Without an valid URL link, you can not use http, and will have to use ftp.
(with an logon and correct password).

Quote:
I have access to a ftp site as well as a http site.
I could probably download from the http site if I could upload to it.
However my version of InetTransferLib did not include http upload
capabilities.
Or am I missing something obvious?
-----

Well, the library does include upload ability, and my 1st example was as
such:

My example to upload was:

Dim f As New FTP


f.FtpURL = "ftp://www.mywebsite.com"
f.SourceFile = "c:\abc.txt"
f.DestinationFile = "/wwwroot/test/abc.txt"
f.ConnectToFTPHost "my user name", "my pass word"
f.UploadFileToFTPServer

Remember, the above code can't be placed in the existing code modules you
imported. (they are class objects and thus you MUST create an instance of
the object as the above code does.)

The dim f as new FTP creates an "new" instance of the FTP code module, and
you must do this.

As mentioned, in the above example, note careful the destination file. The
ftp URL must be the base web site name, and then the destination file needs
the correct path name and also the file name.

The connectToFTPHost command needs your correct logon name and also your
correct password.

Note that the order of above 1st 3 commands is not 100% important. The last
two (connect and upload) most certanly have to come in the correct order and
occur after the other settings.

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal (AT) msn (DOT) com

Reply With Quote
  #9  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: FTP Upload Download - 01-15-2010 , 11:55 AM



"Lou O" <lgeastwood (AT) gmail (DOT) com> wrote


Quote:
I could probably download from the http site if I could upload to it.
However my version of InetTransferLib did not include http upload
capabilities.
Or am I missing something obvious?


Ah, yes, I don't think very many web servers allow https uploads, as this
means you don't usually need a user name or password. if you could do this,
then just about anyone could upload files to your system, and even worse,
the web pages are simply files that are sitting on the web server. If you
let me upload files, then I could change your web site to anything I want.
in fact, this is how hackers often de-face or mess up existing web sites.

So, it highly unlikely that your web server is setup to allow http uploads,
and it is little, if any surprise that http uploads are not part of this
library. In fact, I not even sure if https uploads are possible without
something being setup on the web page itself...


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal (AT) msn (DOT) com

Reply With Quote
  #10  
Old   
Lou O
 
Posts: n/a

Default Re: FTP Upload Download - 01-15-2010 , 03:11 PM



Quote:
Great, the above is likely 99% of the goal here. It means
you have imported the library correctly, and now have it
works.

Yes that is one of the goals. But how do I get a file onto my server
for downloading? That's what I thought the uploading function is for.
Please bear with me.
Should I understand that the process and options basically is as
follows?
1. upload files onto the ftp area on the server. (using ftp method)
2. download files from the ftp area on the server. (using ftp or http
methods)

If I browse the ftp site I can see the following file structure
ftp://uploads.mywebsite.ca/test/
In explorer I can drag and drop files into both the root and test
folders

following are the ftp parameters for my web site I've been given.

ftp://uploads.mywebsite.ca
username "myusername"
password "mypassword"

using the above parameters in InetTransferLib I have the following
code firing on a button click in a test form module .

Set f = New FTP
f.FtpURL = "ftp://uploads.mywebsite.ca"
f.SourceFile = "C:\myFolder\test.txt"
f.DestinationFile = "/test/test.txt.accdb"
f.ConnectToFTPHost "myusername", "mypassword"
f.UploadFileToFTPServer
Set f = Nothing

using the ftp library as above I continue to get file copy failure in
the UploadFileToFTPServer function.
I can't get the file to write to the server (except by drag and drop
but that's not the idea hear)

Quote:
Remember, the above code can't be placed in the existing code modules you
imported. (they are class objects and thus you MUST create an instance of
the object as the above code does.)
As I noted above, the code fires on a button click on a test form.

Quote:
As mentioned, in the above example, note careful the destination file. The
ftp URL must be the base web site name, and then the destination file needs
the correct path name and also the file name.
I get no errors such as URL not found.

Quote:
The connectToFTPHost command needs your correct logon name and also your
correct password.
I can connect correctly in windows explorer as well as the lib
ConnectToFTPHost function without errors.

Quote:
Note that the order of above 1st 3 commands is not 100% important. The last
two (connect and upload) most certanly have to come in the correct order and
occur after the other settings.
Noted and observed.

But oddly my problem remains. I cannot get the file to write to the
server.
It seems I've done everything right.
What else could possibly be causing the problem?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.