Solved

How can I upload a file from form to ASP file?

Posted on 2004-09-06
9
177 Views
Last Modified: 2012-05-05
Let's say I have opendialog component with it's value FileName.
Then I have ASP based web page, which should basically accept file upload.

I have found some examples of ASP page, but I have no Idea how to send info to ASP page.

Which components should I use?
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
  • 4
9 Comments
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 11988917
It depends on how works the ASP webpage...

For example if the only needs is to pass a parameter to the asp page you can simply use the Browser passing the parameters to it...

something like:
uses
shellapi

ShellExecute(0,'open',PChar('www.somesite.com\uploadpage.asp?File='+filename),nil,nil,0);
0
 
LVL 1

Author Comment

by:Povilas
ID: 11988967
I would like something without opening browser. I really need something that would let me upload file to a web server and basically only from Delphi form.
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 11989031
so you could use a ftp uploader component like indy tidFTP, but this means that you have to build a FTP location on your site.

Then from your application you can easly let the user to select the file and send it via ftp using your ftp connection settings directly from your application.

You can find the component and a FTPDemo on http://www.indyproject.org/
0
Technology Partners: 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!

 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 11989042
0
 
LVL 1

Author Comment

by:Povilas
ID: 11989178
I have found this tutorial:
http://www.matlus.com/scripts/website.dll/Tutorials?DelphiTCPIP&IndyMultiPartFormData&5

The problem is that server side code is not available and project file download doesn't work :-(
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 125 total points
ID: 11989245
Form me all is working fine....

BTW i've downloaded it and moved to my ftp... you can get it here now
www.afsoftware.it\Downloads\IndyMultipartFormData.zip
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 11989450
BTW using a TidFTP you can do this

procedure TForm1.Button1Click(Sender: TObject);
begin
If OpenDialog1.execute then
   begin
      with IdFtp1 do begin
         Host := 'ftp.somesite.com'; //your site ftp address
         UserName := 'User'; //the site username
         Password := 'Password'; //and the password
         try
            Connect;
            ChangeDir('/UploadDir'); //go to the dir on the site where you have to upload the file
            TransferType := ftBinary;
            IdFTP1.Put(OpenDialog1.FileName, ExtractFileName(OpenDialog1.FileName)); //and upload the file
         finally
            IdFTP1.Quit;
         end;
      end;
    end;
end;
0
 
LVL 1

Author Comment

by:Povilas
ID: 11995112
There are problems:

//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
 
LVL 1

Author Comment

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

Featured Post

Technology Partners: 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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 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