|
-
Nov 2nd, 2006, 01:25 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Uploading any file via FTP to a ftp server - INCLUDES WORKING SOURCE CODE
I'm just wondering is there any way to do this in VB without the extremely long API or extra modules or anything - like using components such as Winsock or Inet (I've heard it is possible, but maybe that's rubbish).
I haven't got a problem with API or extra modules. It's just that I'm going to need this for a college project which is going to be examined, and I'd rather go through the hassle (if it's worth the time) of learning how to use the control and then using it in my own project. I'd rather not use someone else's code since
1) I'm going to have to reference that in my coursework, which might make examiners go "oh, this person doesn't know real solid programming. He's just copied and pasted anything he could find off the internet. Even a baby can do that!"
2) I could just not reference that, but thats really wrong and they'd probably suspect with all the commenting like
VB Code:
'FTP Transfer via API
'(c) John Smith 2005. You can freely distribute this code
'Website: [url]http://www.planetsourcecode.com[/url]
'...
If you could come up with something, then that would be absolutely brilliant. I've tried PlanetSourceCode already and have searched the forums. By the way, I am handing reps out 
kregg
Last edited by kregg; Nov 2nd, 2006 at 02:48 PM.
-
Nov 2nd, 2006, 01:33 PM
#2
Re: Uploading a CSV file via FTP to a ftp server
What if you learn how to use the API ?
-
Nov 2nd, 2006, 01:38 PM
#3
Re: Uploading a CSV file via FTP to a ftp server
 Originally Posted by kregg
.... By the way, I am handing reps out...
That's the least we need...
Anyway, try using MS Internet Transfer control (aka INet). It's very simple to use and we have tons of samples available.
-
Nov 2nd, 2006, 02:46 PM
#4
Thread Starter
Fanatic Member
Re: Uploading a file via FTP to a ftp server
@CVMicheal, if it's small amounts, then OK I would, but the problem is that I've figured out how to do this INet thing. Sorry 
@Rhinobull, Ok, Ok! I won't give you reps, Mr Rolleyes
Anyways, I've figured out how to do this. Took me long enough, but with enough scoundering on the web, I have finally done it . I'm going to post my code since every single post I found didn't have the completed solution - which doesn't exactly help anybody when they're trying to search.
VB Code:
'Stick this into a command button
With iNet1
.AccessType = icDirect 'Keep the same
.Protocol = icFTP 'Keep the same
.UserName = "your username here"
.Password = "your password here"
.RemoteHost = "ftp:// and your server here - MUST include ftp!"
.Execute , "PUT [the file you want to send from your harddisk] [the file you want to save it as when it reaches the server]" 'ALWAYS USE PUT
While StillExecuting
DoEvents
Wend
.Execute , "CLOSE"
End With
Example:
VB Code:
Public Sub Command1_Click()
With iNet1
.AccessType = icDirect
.Protocol = icFTP
.UserName = "johnsmith"
.Password = "johnsmith"
.RemoteHost = "ftp://johnsmith.com"
.Execute , "PUT C:\thingstodo.txt todolist.txt"
While .StillExecuting
DoEvents
Wend
.Execute , "CLOSE"
End With
End Sub

EDIT: Added While and WEnd code. Tried this out on another PC and this is successful. If the file doesn't upload you haven't typed in the correct location of the file you wish to upload - I know because it happened to me. The extra code just prevents it from saying "Still Executing last Request", Error number 35764
Last edited by kregg; Nov 2nd, 2006 at 04:00 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|