Solved

Automated file upload Delphi -> ASP help needed

Posted on 2004-09-07
5
657 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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