Automated file upload Delphi -> ASP help needed

Posted on 2004-09-07
Last Modified: 2012-05-05
I have example, but it does not work with ASP. I did get this code to write some data, like :
 'file one content. Contant-Type can be application/octet-stream or if '+
  'you want you can ask your OS fot the exact type.
Unfortunately it can't upload new files. Server side must be ASP.

//Delphi procedure:
procedure TForm1.Button2Click(Sender: TObject);
Const CRLF = #13#10;
Var aStream: TMemoryStream;
      Params: TMemoryStream;
      S: String;
 aStream := TMemoryStream.create;
 Params := TMemoryStream.Create;
 HTTP.Request.ContentType := 'multipart/form-data; boundary=-----------------------------7cf87224d2020a';
  S := '-----------------------------7cf87224d2020a' + CRLF +
  'Content-Disposition: form-data; name="csv"; filename="d:abc.csv"' + CRLF +
  'Content-Type: text/plain' + CRLF + CRLF +
  'file one content. Contant-Type can be application/octet-stream or if '+
  'you want you can ask your OS fot the exact type.' + CRLF +
  '-----------------------------7cf87224d2020a' + CRLF +
  'Content-Disposition: form-data; name="game_number"' + CRLF + CRLF + 'hello2' + CRLF +
 Params.Write(S[1], Length(S));
 with HTTP do begin
  HTTP.Post('', Params, aStream);
 on E: Exception do
 showmessage('Error encountered during POST: ' + E.Message);
aStream.WriteBuffer(#0' ', 1);

is there simplier example?
Question by:Povilas

Author Comment

ID: 11997190
I found this example that works:
LVL 26

Expert Comment

ID: 12010331
First off, I don't see where you are loading the file into your stream at all.
I'd suggest looking at Shiv Kumar's Upload tutorial here:

Accepted Solution

modulo earned 0 total points
ID: 13432771
PAQed with points refunded (125)

Community Support Moderator

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now