FTP Upload

  • VB.NET
    Hallo

    Ich habe vor in einem Programm ein FTP Upload Button eizufügen der dann auf einer neuen Form zu weißt das funktioniert auch schon nur habe ich Probleme mit dem FTP Upload code bei mir sagt er, wenn ich den code im meinem Beitrag ausführen will:
    Ausnahmefehler während einer WebClient-Anforderung.

    hier meine codes:

    PHP datei:

    PHP-Quellcode

    1. <?php
    2. $returnValue = "FAIL";
    3. if(isset($_GET['Dir']))
    4. {
    5. $uploaddir = $_GET['Dir'];
    6. if (is_uploaded_file($_FILES['file']['tmp_name']))
    7. {
    8. $uploadfile = $uploaddir.basename($_FILES['file']['name']);
    9. if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))
    10. {
    11. $returnValue = "SUCCESS";
    12. }
    13. }
    14. }
    15. echo $returnValue;
    16. ?>


    Hier die beiden codes con VB:

    VB.NET-Quellcode

    1. Private Function UploadFile(ByVal filename As String, ByVal uploaddir As String) As Boolean
    2. Dim Client As New System.Net.WebClient()
    3. Client.Encoding = System.Text.Encoding.Default
    4. Client.Headers.Add("Content-Type", "binary/octet-stream")
    5. Dim result As Byte() = Client.UploadFile("http://h4you.bplaced.de/ftpup/upload.php?Dir=" + uploaddir, "POST", filename)
    6. Dim response As String = System.Text.Encoding.Default.GetString(result, 0, result.Length)
    7. If response = "SUCCESS" Then
    8. Return True
    9. Else
    10. Throw New Exception(response)
    11. End If
    12. End Function


    VB.NET-Quellcode

    1. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    2. If UploadFile("C:\test.bmp", "/ftpup") Then
    3. MsgBox("Datei erfolgreich hochgeladen")
    4. End If
    5. End Sub


    Ich hoffe ihr könnt mir helfen

    MfG Germanys-Life