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
ASKED:
June 1, 2011 2:26 PM
UPDATED:
June 8, 2011 4:58 PM
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
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.
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.
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.
Thanks Carlos for the help file.
MicrosoftSite
That link has all the commands you will need and does a good job with their examples
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..
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 IfIn 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.
Sorry, I forgot to escape the backslash (again):
This line looked incorrect in my previous post:
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.
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.
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
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.
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.
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?
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.
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.
Here’s my code at latest trials
Can you see any issues; on my end it all appears to work,, no errors, and heres your code using my file as
but as I’ve stated before, at the end of it all, the data at the other end is not changed.
Now I left out the in my post but in the file code, it is
Don’t include the name of the file in the URL.
Try replacing this:
with this:
So, the code should look like this:
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.
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).
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.
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?
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!
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.
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?
“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.
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.
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.
… … … ??
@Carlosdl
How do we send emails to one another here? Did I overlook this feature?
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.