Results 1 to 4 of 4

Thread: [RESOLVED] Uploading any file via FTP to a ftp server - INCLUDES WORKING SOURCE CODE

  1. #1

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Resolved [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:
    1. 'FTP Transfer via API
    2. '(c) John Smith 2005. You can freely distribute this code
    3. 'Website: [url]http://www.planetsourcecode.com[/url]
    4. 'Email: [email][email protected][/email]
    5. '...

    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.

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Uploading a CSV file via FTP to a ftp server

    What if you learn how to use the API ?

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Uploading a CSV file via FTP to a ftp server

    Quote 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.

  4. #4

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    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:
    1. 'Stick this into a command button
    2.     With iNet1
    3.         .AccessType = icDirect     'Keep the same
    4.         .Protocol = icFTP             'Keep the same
    5.         .UserName = "your username here"
    6.         .Password = "your password here"
    7.         .RemoteHost = "ftp:// and your server here - MUST include ftp!"
    8.         .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
    9.          While StillExecuting
    10.             DoEvents
    11.         Wend
    12.         .Execute , "CLOSE"
    13.     End With

    Example:
    VB Code:
    1. Public Sub Command1_Click()
    2.     With iNet1
    3.         .AccessType = icDirect
    4.         .Protocol = icFTP
    5.         .UserName = "johnsmith"
    6.         .Password = "johnsmith"
    7.         .RemoteHost = "ftp://johnsmith.com"
    8.         .Execute , "PUT C:\thingstodo.txt todolist.txt"
    9.          While .StillExecuting
    10.             DoEvents
    11.         Wend
    12.         .Execute , "CLOSE"
    13.     End With
    14. 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
  •  



Click Here to Expand Forum to Full Width