BBC BASIC for Windows
« Uploading to FTP Server »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:02pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Uploading to FTP Server  (Read 1358 times)
pettit
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Uploading to FTP Server
« Reply #4 on: Jun 1st, 2012, 5:43pm »

Thanks again. I have looked at the InternetGetLastResponseInfo function, but feel I am beginning to get rather out of my depth trying to convert it into a BB4W SYS call to retrieve whatever useful information it might provide. I could certainly have an attempt, but the concern would be if it didn't work I wouldn’t know is it was my poor translation of code or merely another unhelpful response from Windows. Any assistance would be appreciated.

Just a thought, I was wondering whether your original code still functions in your own hands, lest impacting changes to dll libraries have since been distributed by Microsoft. Confirmation would be encouraging.
« Last Edit: Jun 1st, 2012, 6:49pm by pettit » User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Uploading to FTP Server
« Reply #5 on: Jun 1st, 2012, 9:54pm »

on Jun 1st, 2012, 5:43pm, pettit wrote:
I have looked at the InternetGetLastResponseInfo function, but feel I am beginning to get rather out of my depth trying to convert it into a BB4W SYS call

This should work:

Code:
      DEF FNlastresponseinfo
      LOCAL bufferlength%, buffer%, wininet%, iglri%, dwerror%
      bufferlength% = 255
      DIM buffer% LOCAL bufferlength%
      SYS "LoadLibrary", "WININET.DLL" TO wininet%
      SYS "GetProcAddress", wininet%, "InternetGetLastResponseInfoA" TO iglri%
      SYS iglri%, ^dwerror%, buffer%, ^bufferlength%
      SYS "FreeLibrary", wininet%
      = $$buffer% 

Quote:
Just a thought, I was wondering whether your original code still functions in your own hands

Yes, my 'uploadftp' program works fine.

For my interest, is the file you are attempting to upload an ASCII file or a binary file, and have you been careful to select the appropriate transfer type (FTP_TRANSFER_TYPE_ASCII or FTP_TRANSFER_TYPE_BINARY)?

Richard.
User IP Logged

pettit
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Uploading to FTP Server
« Reply #6 on: Jun 2nd, 2012, 08:30am »

The small file I am now using with 'ftpupload' is a simple 645 byte (tab delimited) ASCII text file terminated with 0d 0a. I have tried both ASCII and BINARY transfer types with identical outcome.

Thanks for the code to call InternetGetLastResponseInfo, much appreciated. Unfortunately the message yielded when called immediately after the 'FtpPutFile' SYS call is perhaps less than helpful; for ASCII transfer:

'200 Type set to A
200 PORT command successful
'

and for BINARY

'200 Type set to I
200 PORT command successful
'

(My single quotes) If I call GetLastError after rather than before InternetGetLastResponseInfo then the reported code & message are 0 and 'The operation completed successfully', as I guess would be expected.

I am certainly no expert, but is this is beginning to look like an issue concerning interaction with both my 2 different web hosts (PlusNet & Heart Internet) ? Any idea where we can go from here ?
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Uploading to FTP Server
« Reply #7 on: Jun 2nd, 2012, 08:58am »

on Jun 2nd, 2012, 08:30am, pettit wrote:
Any idea where we can go from here ?

To extract more diagnostic information is probably going to need a packet analyzer, so you can monitor exactly the network traffic flowing between your PC and the FTP server. You should then be able to see any unexpected responses (or lack of response!).

You might want to try something like Wireshark:

http://www.wireshark.org/

I presume you find that other FTP clients work correctly, in which case the likelihood is that there's a problem with FtpPutFile. As I expect you're aware, you can do the file transfer at a lower level, in much the same way as the alternative, more complex, PROCurldownload() does here:

http://bb4w.wikispaces.com/Downloading+a+file+from+a+URL

I haven't had to write the equivalent for uploading, but it's certainly possible and would give you more control over exactly what is happening.

Richard.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Uploading to FTP Server
« Reply #8 on: Jun 2nd, 2012, 09:06am »

on Jun 2nd, 2012, 08:30am, pettit wrote:
Any idea where we can go from here ?

One further thought. Some FTP servers require using passive mode, so have you tried setting that in the InternetConnect call:

Code:
SYS `InternetConnect`, hOpen%, "ServerName", FTP_PORT, \
      \       "Username", "Password", SERVICE_FTP, _INTERNET_FLAG_PASSIVE, 0 \
      \       TO hConnection%
 

(use the Add Windows Constants utility to declare the constant).

Richard.
« Last Edit: Jun 2nd, 2012, 09:15am by admin » User IP Logged

pettit
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Uploading to FTP Server
« Reply #9 on: Jun 2nd, 2012, 1:37pm »

Richard your 'further thought' was a gem.

Success !

Setting passive mode in the InternetConnect call as you describe was indeed the solution. Once this SYS call was amended, the Add Windows Constants utility added the line _INTERNET_FLAG_PASSIVE = &8000000 to the BB4W code and all is now well.

Many thanks for your help.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls