Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi TIdMultiPartFormDataStream und AddFile (https://www.delphipraxis.net/37298-tidmultipartformdatastream-und-addfile.html)

endeffects 4. Jan 2005 10:20


TIdMultiPartFormDataStream und AddFile
 
Hallo,

ich verwende die Indy Komponenten um ein POST Formular auszufüllen,
mit Hilfe von TIdMultiPartFormDataStream und Addfile versende ich so
eine Datei an einen Webserver. Das Problem was ich nun habe is dass ich
eine Möglichkeit suche nicht eine lokale Datei sondern einen String
an TIdMultiPartFormDataStream zu übergeben. Die OH ist leider nicht wirklich
aussagekräftig. Hat da Jemand vielleicht eine Idee?

Mal ein paar Codeschnippsel:

Delphi-Quellcode:
    Filestream := TIdMultiPartFormDataStream.Create;
    Filestream.AddFormField('directory', 'test');
    Filestream.AddFile('userfile', 'c:\test.html', 'text/plain');
    Filestream.Position:= 0;
    try
      IdHTTP.Post('http://webserver.tld', Filestream);
    except
        //nix
    end;
(Auf ein Temp-File möchte ich übrigends verzichten)

generic 2. Aug 2006 16:31

Re: TIdMultiPartFormDataStream und AddFile
 
machst du doch bereits mit der zeile:
Delphi-Quellcode:
  Filestream.AddFormField('directory', 'test');

Sascha999999999 28. Sep 2006 22:33

Re: TIdMultiPartFormDataStream und AddFile
 
Liste der Anhänge anzeigen (Anzahl: 1)
habe ein änliches Problem!!!

addFile wird von PHP Script das mit:

<?
print_r($_REQUEST);
print_r($_FILE);
?>

nur user und Hash erkennt. aber nicht File:

HTTP Sniffer:
Delphi-Quellcode:
POST /user/klasse/online/AI601/CMS/upload/cms/upload.php?user=Sascha&hash= HTTP/1.0
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------092806231824670
Content-Length: 558
Host: sascha-net.homeip.net
Accept: text/html, */*
Accept-Encoding: deflate, gzip, identity
User-Agent: AIcms

----------092806231824670
Content-Disposition: form-data; name="user"

Sascha
----------092806231824670
Content-Disposition: form-data; name="hash"


----------092806231824670
Content-Disposition: form-data; name="file"; filename="C:\WINDOWS\DESKTOP\WEB-FTP\FILE_UPLOAD\6\temp\31884.cab"
Content-Type: application/x-cab-compressed



MSCF....³.......,...................E.......e.........15²ž`.Head.txt.8Cæêf.e.CKó.      Ð7Ô3T020Pð÷æårI,IµR..ÍÓQ04W.N-.ɘ).ZZ™šX..(¸û†ðr9ç畤æ•è–T...—¤V”èg”äæX+$g$..§–Øf.çëZX˜Zê.òrñr..
----------092806231824670--
HTTP/1.1 200 OK
Date: Thu, 28 Sep 2006 21:18:19 GMT
PICS-Label: (PICS-1.0 "http://www.rsac.org/ratingsv01.html" l on "2005.06.04T16:02+0200" exp "2006.06.04T12:00+0200" r (v 0 s 0 n 0 l 0))
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
Content-type: text/html; charset=iso-8859-1

Array
(
    [user] => Sascha
    [hash] =>
)
Der delphi Code:
Delphi-Quellcode:
ResponseInfo:=TIdMultiPartFormDataStream.Create;
ResponseInfo.AddFormField('user', ini.ReadString('Benutzerdaten', 'Username', ''));
ResponseInfo.AddFormField('hash', encode64(ini.ReadString('Benutzerdaten', 'PasswdHash', '')));
ResponseInfo.AddFile( 'file', achiv, 'application/x-cab-compressed' );
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
idHTTP1.POST('http://sascha-net.homeip.net/user/klasse/online/AI601/CMS/upload/cms/upload.php?user='+ini.ReadString('Benutzerdaten', 'Username', '')+'&hash='+code(ini.ReadString('Benutzerdaten', 'PasswdHash', '')), ResponseInfo);
idHTTP1.Free;
kann mir jemand helfen?

meine IdMultipartFormData.pas ist im Anhang, eventuel liegt da ja der Fehler...


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:27 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz