Jump to content
xisto Community
Sign in to follow this  
oncombeureum

Uploading File Using Delphi To A Php Upload Script delphi 6 would be prefered

Recommended Posts

simple question:how to upload files using delphi, using http protokol that will be received by php script ?ex:delphi ---------------> http://imptestrm.com/rg-erdr.php?_dnm=www.giveittome.com&_cfrg=1&_drid=as-drid-2300300503455222 Beureum

Edited by microscopic^earthling (see edit history)

Share this post


Link to post
Share on other sites

simple question:

 

how to upload files using delphi, using http protokol that will be received by php script ?

 

ex:

delphi ---------------> http://imptestrm.com/rg-erdr.php?_dnm=www.giveittome.com&_cfrg=1&_drid=as-drid-2300300503455222

thanks

 

Oncom Beureum

1064306059[/snapback]


You can do this using Indy that comes with Delphi. It involves two things. TIdHTTP and TIdMultipartFormDataStream.

 

Add IdMultipartFormData to your uses clause. Drop TIdHTTP (which is in Indy Clients tab of Component Palette ) on to your form. Set whatever properties of TIdHTTP you want. Now if you were wanting the file to be uploaded after a button has been clicked then put this in the event handler you assigned for the buttons OnClick event.

 

procedure TFormClassNameHere.EventHandlerNameHere( Sender : TObject )var  Stream            : TIdMultipartFormDataStream;begin  Stream := TIdMultipartFormDataStream.Create;  try    Stream.AddFile( 'form_field_name_here', 'filename_here', 'content-type_here' );    IdHTTP1.Post( 'url_here', Stream );  finally    Stream.Free;  end;end;

That's basically it. If you have any questions then please feel free to ask. I'm quite proficient in Delphi.

 

Regards, Digital Technic.

 

p.s. If you need an example to be attached I could provide that too.

Share this post


Link to post
Share on other sites

You can do this using Indy that comes with Delphi. It involves two things. TIdHTTP and TIdMultipartFormDataStream.

 

yeah, but what if im making a ASP.NET app, cant use Indy ,can I ? then how do I select the file to upload since it doesnt provide dialog box compomnents.

 

Thanx,

Aryan

Share this post


Link to post
Share on other sites

Do you have available the example again?I need to upload a file using delphi 6 and IdHTTP 8.0.25Regards,Álvaro.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.