Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   Enviar archivo a mi servidor o web? (https://www.clubdelphi.com/foros/showthread.php?t=64193)

c0lo 21-03-2009 02:59:49

Enviar archivo a mi servidor o web?
 
Bueno ahora os molesto con algo que no se como iniciar y si alguien tiene un ejemplo que me sirva super...

Bueno quiero por medio de delphi hacer un uploader para subir conc presionar un boton un archivo a mi servidor o pagina web...

Gracias

JXJ 21-03-2009 19:30:44

quieres subir archivos a tu servidor web..
entonces. tu servidor web ¿ permite usar FTP?
o solo subir por su pagina web.. com muchos web hosting gratuitos..
si es subir via web ya sabes que combinacion de url y password se usan
ejemplo

http://www.tuservidorweb.com/usuario...er/archivo.zip

entonces hacerlo automatico requieres de el componente tidhttpclient de los indy
para hacer uso de los comandos post o get para obtener info

si es por ftp indy y TidFTPclient.

c0lo 22-03-2009 04:22:08

Bueno usar una conexion FTP para un programa publico no es conveniente ya que si snifeas los archivos se mostraran tus datos, como hosting, user and pass. La mejor solucion es usar un FTPS.

Pero hay una solucion mas sencilla que seria "Uploading File Using Delphi To A Php Upload Script"

Cita:

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.

Código:

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;


Esta seria la solucion mas practica y segura en un sentido, ya que tendrias que proteger tu aplicacion de tal forma no sepan como subes un archivo a tu ftp, ya que podrian meter una shell o algo similar y poder tener el control de tu ftp.. mediante algun tipo de inyeccion.


La franja horaria es GMT +2. Ahora son las 08:13:33.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi