Solved

Automated file upload Delphi -> ASP help needed

Posted on 2004-09-07
5
654 Views
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;
begin
 aStream := TMemoryStream.create;
 Params := TMemoryStream.Create;
 HTTP.Request.ContentType := 'multipart/form-data; boundary=-----------------------------7cf87224d2020a';
 try
  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 +
  '-----------------------------7cf87224d2020a--';
 Params.Write(S[1], Length(S));
 with HTTP do begin
  try
  HTTP.Post('http://www.test.com/test_upload.asp', Params, aStream);
 except
 on E: Exception do
 showmessage('Error encountered during POST: ' + E.Message);
 end;
 end;
aStream.WriteBuffer(#0' ', 1);
showmessage(PChar(aStream.Memory));
except
end;
end;

is there simplier example?
0
Comment
Question by:Povilas
5 Comments
 
LVL 1

Author Comment

by:Povilas
ID: 11997190
I found this example that works:
http://4homepages.de/forum/viewtopic.php?t=4786
0
 
LVL 26

Expert Comment

by:EddieShipman
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:
http://www.matlus.com/scripts/website.dll/Tutorials?DelphiTCPIP&IndyMultiPartFormData&5
0
 

Accepted Solution

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

modulo
Community Support Moderator
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…

829 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