vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Schützen Sie Ihre Software vor Software-Piraterie - mit sevLock 1.0 DLL!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2024
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Ein- und Umsteiger
Datei per Post an Server übertragen 
Autor: TAiS46
Datum: 20.09.08 12:56

Hallo,

ich versuche verzweifelt eine Datei an ein PHP Script zu Posten was aber nicht klappt.
PHP Antwortet mir immer nach dem Upload: Value: 3; The uploaded file was only partially uploaded.

Content-Length sollte auch alles stimmen.
Als Header Ausgabe bekomme ich folgendes von PHP:

 
Array
(
    [CONTENT_TYPE] => multipart/form-data; _
      boundary=---------------------------633575120292187500
    [HTTP_REFERER] => http://***.de/test/upload.php
    [HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; _
      Trident/4.0; .NET CLR 2.0.50727; .NET CLR
    [HTTP_ACCEPT] => Accept: image/gif, image/x-xbitmap, image/jpeg, _
    image/pjpeg, application/x-shockwave-flash, application/x-icq, _
    application/vnd.ms-powerpoint, application/msword, _
    application/vnd.ms-excel, application/x-ms-application, _
    application/x-ms-xbap, application/vnd.ms-xpsdocument, _
    application/xaml+xml, application/x-silverlight, */*
    [HTTP_HOST] => ***.de
    [CONTENT_LENGTH] => 1410
    [HTTP_CONNECTION] => Keep-Alive
    [PATH] => /usr/local/bin:/usr/bin:/bin
    [SERVER_SIGNATURE] => <address>Apache/2.2.3 (Debian) PHP/5.2.6-0.dotdeb.1 _
      with Suhosin-Patch mod_perl/2.0.2 Perl/v5.8.8 Server at ***.de Port _
      80</address>
 
    [SERVER_SOFTWARE] => Apache/2.2.3 (Debian) PHP/5.2.6-0.dotdeb.1 with _
      Suhosin-Patch mod_perl/2.0.2 Perl/v5.8.8
    [SERVER_NAME] => ***.de
    [SERVER_ADDR] => 91.***
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 77.***
    [DOCUMENT_ROOT] => /var/www/site/htdocs
    [SERVER_ADMIN] => support@dataup.de
    [SCRIPT_FILENAME] => /var/www/site/htdocs/test/upload.php
    [REMOTE_PORT] => 2218
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => POST
    [QUERY_STRING] => 
    [REQUEST_URI] => /test/upload.php
    [SCRIPT_NAME] => /test/upload.php
    [PHP_SELF] => /test/upload.php
    [REQUEST_TIME] => 1221908028
    [argv] => Array
        (
        )
 
    [argc] => 0
)
Und hier nun noch der Code von mir


        Dim FileName As String = "sti.log"
        Dim location As String = "C:\sti.log"
        Dim boundary As String = "---------------------------" & _
          DateTime.Now.Ticks.ToString
 
        Dim req As Net.HttpWebRequest = Net.HttpWebRequest.Create( _
          "http://'''.de/test/upload.php")
        req.Credentials = System.Net.CredentialCache.DefaultCredentials
        req.Method = "POST"
        req.KeepAlive = True
        req.ContentType = "multipart/form-data; boundary=" & boundary
        req.Referer = "http://'''.de/test/upload.php"
        req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;" & _
          "Trident/4.0; .NET CLR 2.0.50727; .NET CLR"
        req.Accept = "Accept: image/gif, image/x-xbitmap, image/jpeg," & _
        "image/pjpeg, application/x-shockwave-flash, application/x-icq," & _
        "application/vnd.ms-powerpoint, application/msword," & _
        "application/vnd.ms-excel, application/x-ms-application," & _
        "application/x-ms-xbap, application/vnd.ms-xpsdocument," & _
        "application/xaml+xml, application/x-silverlight, */*"
        req.ServicePoint.Expect100Continue = False
 
        Dim boundarybytes() As Byte = System.Text.Encoding.ASCII.GetBytes("--" _
          & boundary & Environment.NewLine)
        Dim infobytes() As Byte = System.Text.Encoding.ASCII.GetBytes( _
        "Content-Disposition: form-data; name=""datei""; filename=""" & _
        FileName & """" & Environment.NewLine & "Content-Type:" & _
        "multipart/form-data" & Environment.NewLine)
 
        req.ContentLength = boundarybytes.Length + infobytes.Length
 
        Dim fileinfo As New IO.FileInfo(location)
        req.ContentLength += fileinfo.Length
 
        Dim reqstream As IO.Stream = req.GetRequestStream
 
        reqstream.Write(boundarybytes, 0, boundarybytes.Length)
        reqstream.Write(infobytes, 0, infobytes.Length)
 
        Dim FileStream As IO.FileStream = IO.File.Open(location, _
          IO.FileMode.Open)
 
        Dim buffer(1023) As Byte
        Dim bytesRead As Integer
 
        Do
            bytesRead = FileStream.Read(buffer, 0, buffer.Length)
            reqstream.Write(buffer, 0, bytesRead)
        Loop Until bytesRead = 0
 
        FileStream.Close()
        reqstream.Close()
 
 
        Dim resp As Net.HttpWebResponse = req.GetResponse
        Dim reader As IO.StreamReader = New IO.StreamReader( _
          resp.GetResponseStream())
 
 
        Dim responseFromServer As String = reader.ReadToEnd()
        Form1.TEMP.Text = (responseFromServer)
 
        reader.Close()
        resp.Close()
        Form1.Show()
Danke, Gruß Simon
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Datei per Post an Server übertragen2.468TAiS4620.09.08 12:56
Re: Datei per Post an Server übertragen1.294TAiS4620.09.08 14:45

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2024 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel