How can I send data out using Microsoft Internet transfer control?

1940 pts.
Tags:
Microsoft Internet Transfer Control
VB
Visual Basic
Windows XP
The other day I learned about a module in Visual Basic called Microsoft Internet transfer control, And it was needed to get me information from the internet to my program, that is now working beautifully, now I’d like to learn how to go the other way using the same module if possible, I want to put data in a file that is sitting on the root of my server. Can anyone assist in showing me this procedure? When I try to get help within my VB program on the module I get the message “Can’t fine file INET98.CHM” so I can’t get any help locally, so also if anyone reading this has that file, I would appreciate it if you would e-mail it to me at kleboeuf@hughes.net also. Thank you in advance for your time and patience in this matter. Oh, yea, I would like to learn both to append data out to the net and write data out to the Internet.

Software/Hardware used:
PC, Window XP

Answer Wiki

Thanks. We'll let you know when a new response is added.

You may find some useful examples here:

http://wiki.robotz.com/index.php/Internet_Transfer_Control_in_VB6

If you change the FTP example’s “GET” command to a “PUT”, it should allow you to FTP out a file. Is that what you are looking for?

Discuss This Question: 32  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Yes, I think TheFinder will need to use FTP. That is what he is looking for, although at this moment he might not know it ;-)
    68,710 pointsBadges:
    report
  • TheFinder
    Thanks Guys, Yes, File Transfer Protocol (FTP) is exactly what I want to do using the Microsoft file transfer control, but my help file is not installed nor can I find it on my Install CD. Now that you stated to change Get to Put, I checked and can’t find either Get or Put in any of the coding I did, but as we speak it will go out and come back with data from my web site, but on a test basis I can not get it to Put data out, any other ideas, and also if anyone has that help file INET98.OCX file, I could sure use it now. Thank you all.
    1,940 pointsBadges:
    report
  • TheFinder
    Here is some of my test code that I'm using to learn with
    Senddata = Form1.Text1.Text
        urltofile = "https://www.birthdayfinder.org/update_nameoffile.txt"
        Senddata = Inet1.OpenURL(urltofile, icString)
    
    Can someone assist me in what I need to add or help me to receive the help file. Thank you.
    1,940 pointsBadges:
    report
  • carlosdl
    Koohiisan was talking about changing GET to PUT in one of the examples from http://wiki.robotz.com/index.php/Internet_Transfer_Control_in_VB6 P.s. I've just emailed you the CHM file.
    68,710 pointsBadges:
    report
  • TheFinder
    Thanks Carlos for the help file.
    1,940 pointsBadges:
    report
  • RamseyB
    report
  • RamseyB
    That link has all the commands you will need and does a good job with their examples
    2,115 pointsBadges:
    report
  • TheFinder
    I'm starting to believe that you can't send data out (Upload) using this Transfer control except locally, not over the net, but you can get files or file information sent back to you from over the Internet. Input, but not output over the net..
    1,940 pointsBadges:
    report
  • carlosdl
    I used one of the examples from the great page posted by RamseyB, and it [almost] worked for me. Closing the connection immediately after sending the file generates an error, because the sending is still in progress. After a small modification it worked for me. This is the code I used:
    Private Sub Command2_Click()
    
    With Inet1
    .URL = "ftp://www.cadlg.com"
    .UserName = "my_ftp_user"
    .Password = "my_ftp_password"
    .Execute , "PUT C:ftp_test.txt /ftp_test.txt"
    End With
    
    End Sub
    
    Private Sub Inet1_StateChanged(ByVal State As Integer)
    If State = icResponseCompleted Then
        Inet1.Execute , "CLOSE"
        MsgBox ("finished")
    End If
    In summary, when the button is clicked the Inet control connects to the site and sends the file, and when the Inet control's state changes to icResponseCompleted, I close the connection. Give it a try.
    68,710 pointsBadges:
    report
  • carlosdl
    Sorry, I forgot to escape the backslash (again): This line looked incorrect in my previous post:
    .Execute , “PUT C:\ftp_test.txt /ftp_test.txt”
    68,710 pointsBadges:
    report
  • TheFinder
    Carlosdl, I know you prob. did, but I have to ask, "did you check the data" to see if it was really written, I have tried your code and my file, and then checked the file out on the net and and it was not changed, even though the code appeared to of worked.
    1,940 pointsBadges:
    report
  • carlosdl
    Yes, I did. Have you tried putting the file manually (using the same credentials), from the command line, to see if it works ? It could be a permissions issue.
    68,710 pointsBadges:
    report
  • TheFinder
    Carlosdl, Yes, I do it all the time, but I normally use my WS_FTP program, I don't know why it's not working using inet, but here's another bit of information I really don’t want to transfer a file only data to a file, here’s how my initial code is
    If Form1.Text1.Text <> "" Then
    Senddata = Form1.Text1.Text
    Else:
    MsgBox "Data is blank"
    GoTo jumphere2
    End If
    
    So you see, it’s not really a file I want to upload, even though I did try that to no avail. Any solutions to this method of me typing my data in a text box and having inet. send it to a file out on my server. I’m wanting this so I can just type in the latest update data and then when someone using my other programs do a check for updates, the data will be there easier for me this way then to update file locally and then send it out that like 2 or 3 steps, I’m trying to merge into one. Thank you for the .txt .chm file as well I'll let you know how that goes. Any and all help is appreciated Thank you all.
    1,940 pointsBadges:
    report
  • carlosdl
    That is not possible. FPT is a protocol to transfer files, so your only option would be to modify the file locally and send it to your site to replace the old one.
    68,710 pointsBadges:
    report
  • TheFinder
    Transferring entire file was my orig. intent, but since I could not get that to work, I've decided to try and find a new way and now this is what I would like to do, but so far neither way seems to work for me, so I might as well try and find a way to transfer data, not file. Can you assist?
    1,940 pointsBadges:
    report
  • carlosdl
    To do that you would need a web service or other application listening on the remote site, which could receive the data and append it to the file. The easiest method would be FTP'ing the complete file. Don't give up, you can make it work. ;-)
    68,710 pointsBadges:
    report
  • TheFinder
    Well, if I could get the transfer control to work, I would still write code to put the data from the textbox into the file, and then upload file but I can’t seem to get it to upload even entire file just yet. I just don’t get it, I used your code of which you said works for you, but here it’s appearing to work, but when I check file on internet it’s still got the same data in it as it did before I did transfer, so for some reason even though it appears to of worked it’s not, and my help file is not working so I can’t seem to get assist from that. I can't see giving up, I will proceed some how. Thank you.
    1,940 pointsBadges:
    report
  • TheFinder
    Here’s my code at latest trials
    Inet1.Execute "ftp://www.mywebsite.org/testfile.txt", _
    "PUT C:testfile.txt /ftp://www.mywebsite.org/testfile.txt"
    
    Can you see any issues; on my end it all appears to work,, no errors, and heres your code using my file as
    With Inet1
    .URL = "ftp://www.mywebsite.org/testfile.txt"
    .UserName = "myusername"
    .Password = "mypasscode"
    .Execute , "PUT C:testfile.txt /testfile.txt"
    End With
    
    but as I've stated before, at the end of it all, the data at the other end is not changed.
    1,940 pointsBadges:
    report
  • TheFinder
    Now I left out the in my post but in the file code, it is
    "PUT C:what2say.txt /ftp://www.birthdayfinder.org/what2say.txt"
    
    1,940 pointsBadges:
    report
  • carlosdl
    Don't include the name of the file in the URL. Try replacing this:
    .URL = “ftp://www.mywebsite.org/testfile.txt”
    with this:
    .URL = “ftp://www.mywebsite.org”
    So, the code should look like this:
    With Inet1
    .URL = “ftp://www.mywebsite.org”
    .UserName = “myusername”
    .Password = “mypasscode”
    .Execute , “PUT C:\testfile.txt /testfile.txt”
    End With
    68,710 pointsBadges:
    report
  • TheFinder
    Yea, I tried that too earlier and just now again, and to no avail, I just don't get it. Except it must be something with VB-4, your prob. Using VB-6 or other version. But I know VB-4 works for reading a file out on the net. But maybe it’s only a one way thing.
    1,940 pointsBadges:
    report
  • Koohiisan
    You could also create your file to be sent, then use the Shell function to run the default FTP program on the computer. You could manipulate the FTP login and commands using SendKeys, or if it allows, override the input with a script (I've never tried that on MS FTP program, so I can't say it works or not).
    5,020 pointsBadges:
    report
  • TheFinder
    Koohiisan Thanks for the new ideas, this is something I can play with and hopefully something will find itself working. LOL. So far for me the inet does not work for uploading files, but only reading files and reporting back. Thanks again for your efforts.
    1,940 pointsBadges:
    report
  • TheFinder
    Now I'm getting the file there, but no data in the file, I'm using the "with" statment as With Inet1 .URL = “ftp://www.mywebsite.org” .UserName = “myusername” .Password = “mypasscode” .Execute , “PUT C:testfile.txt /testfile.txt” End With but at the other end is a blank file, any suggestions?
    1,940 pointsBadges:
    report
  • Koohiisan
    Three thoughts: 1) are you in the proper transfer mode (binary, AsCII)? 2) do you have proper permissions (even though it is creating the file)? 3) try with the opposite kind of slash in the PUT statement Hopefully one of those will do the trick! :)
    5,020 pointsBadges:
    report
  • TheFinder
    I have permissions and have tried to swap out the slashes, but to no avail. I even called my Host provider and they couldn’t find any issues so I don’t know what to do now, but maybe for this project use VB-6 or 2005.
    1,940 pointsBadges:
    report
  • Koohiisan
    If you are creating the file in the program, is it perhaps still held open when you get to the point where you are trying to send it? What happens when you try to send a different file that you program does not create?
    5,020 pointsBadges:
    report
  • carlosdl
    "1) are you in the proper transfer mode (binary, AsCII)? 2) do you have proper permissions (even though it is creating the file)? 3) try with the opposite kind of slash in the PUT statement" Hopefully one of those will do the trick! Not likely, IMO. But this: "If you are creating the file in the program, is it perhaps still held open when you get to the point where you are trying to send it" is an excellent observation ! I agree, that could be the cause.
    68,710 pointsBadges:
    report
  • TheFinder
    The file is not created by the program, it is already sitting on my HD. In my program I just code for it to send the pre made file to my url.
    1,940 pointsBadges:
    report
  • carlosdl
    Kurt, if you can create a test FTP account I can try sending a file from my test program. E-mail me the details, and I'll run the test.
    68,710 pointsBadges:
    report
  • Koohiisan
    ... ... ... ?? @Carlosdl How do we send emails to one another here? Did I overlook this feature?
    5,020 pointsBadges:
    report
  • carlosdl
    Nope. We have exchanged emails with TheFinder in the past, and that is why we have each other's address ;-) It would be a nice ITKE feature though. P.s. If we find a solution with this test, it will be posted here.
    68,710 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following