[code] Upload file to FTP server

Discussion in 'Programming General' started by rofloller, Oct 6, 2008.

[code] Upload file to FTP server
  1. Unread #1 - Oct 6, 2008 at 10:00 AM
  2. rofloller
    Referrals:
    0

    rofloller Guest

    [code] Upload file to FTP server

    Have fun...
    Code:
    Private Sub Command1_Click()
    Me.Caption = "Uploading..."
    If UploadFile("C:\", "file.exe", "admin", "password123", "www.jrantala.com", "crap/") Then
        MsgBox "File uploaded succefully"
    End If
    End Sub
    
    Private Function UploadFile(LocalDir As String, FileName As String, username As String, password As String, FTPserver As String, remoteDir As String)
    Inet.Cancel
    While Inet.StillExecuting
        DoEvents
    Wend
    
    On Error GoTo err
    
    Inet.Execute "FTP://" & username & ":" & password & "@" & FTPserver, "SEND " & Chr(34) & LocalDir & FileName & Chr(34) & " " & Chr(34) & remoteDir & FileName & Chr(34)
    
    While Inet.StillExecuting
        DoEvents
    Wend
    
    Inet.Execute , "CLOSE"
    While Inet.StillExecuting
        DoEvents
    Wend
    UploadFile = True
    Exit Function
    err:
    UploadFile = False
    MsgBox Error
    End Function
     
  3. Unread #2 - Oct 6, 2008 at 11:58 PM
  4. demonavenger
    Joined:
    Feb 25, 2007
    Posts:
    536
    Referrals:
    0
    Sythe Gold:
    0

    demonavenger Forum Addict
    $5 USD Donor

    [code] Upload file to FTP server

    Okay, few things first...

    Since this VB forum, contains many newly members who are wanting to learn how to program in VB, it might help if you put a few comments on how the code works and point out certain important parts to script.

    This script wouldn't be 100% safe if i may add?
    Wouldn't it be possible for someone to find out your FTP user account and password by simply hexing it... if it is reading off a text file, this is even more unsecure...

    I would change your code, and add an encryption (Terrible spelling?)...
    Even a basic encryption would make this code more secure...

    Another thing...
    Code:
    Inet.Execute "FTP://" & username & ":" & password & "@" & FTPserver, "SEND " & Chr(34) & LocalDir & FileName & Chr(34) & " " & Chr(34) & remoteDir & FileName & Chr(34)
    
    The Variables 'username', 'password', etc...
    Where in the script, have you assigned them to contain a value?
     
  5. Unread #3 - Oct 7, 2008 at 3:31 AM
  6. rofloller
    Referrals:
    0

    rofloller Guest

    [code] Upload file to FTP server

    Are you blind?
    Code:
    username As String, password As String
    In the function.

    And when you press command1...
    Code:
    Me.Caption = "Uploading..."
    If UploadFile("C:\", "file.exe", "admin", "password123", "www.jrantala.com", "crap/") Then
        MsgBox "File uploaded succefully"
    End If
     
  7. Unread #4 - Oct 7, 2008 at 11:43 PM
  8. demonavenger
    Joined:
    Feb 25, 2007
    Posts:
    536
    Referrals:
    0
    Sythe Gold:
    0

    demonavenger Forum Addict
    $5 USD Donor

    [code] Upload file to FTP server

    Sorry, missed that in the function >_<

    though, it is still hexable to find out your username and password to the ftp?
     
< Online Guides to Learn C | tab's >

Users viewing this thread
1 guest


 
 
Adblock breaks this site