Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #5  
Antiguo 22-04-2004
Avatar de jachguate
jachguate jachguate is offline
Miembro
 
Registrado: may 2003
Ubicación: Guatemala
Posts: 6.254
Poder: 30
jachguate Va por buen camino
Cool

Dado que el código puede ser de utilidad, me he tomado la libertad de indentarlo y publicarlo en este mensaje, ya que en el original del amigo tetemusic, al menos yo, no lo encontré indentado.

Aclaro que no he revisado su contenido ni la lógica... eso ya quedará para quien quiera aprovecharlo.

Hasta luego.



Código:
const
  CRLF = #13#10;
var
  NomFitxer, path, codi, password: string;
  Config: TInifile;
  aStream: TMemoryStream;
  Params: TMemoryStream;
  S, linea: String;
  F: TextFile;
begin
  //enviamos fichero, sus datos y el user y password están en un .ini
  path := ExtractFilePath(Application.ExeName);
  Config := TIniFile.Create(path+'config.ini');
  with Config do
  begin
    if ReadString('General','Path','Main') <> 'Main' then
      path := ReadString('General','Path','Main');
    if ReadString('General','Codi','Main') <> 'Main' then
      codi := ReadString('General','Codi','Main');
    if ReadString('General','Password','Main') <> 'Main' then
      password := ReadString('General','Password','Main');
    Free;
  end;
  OpenDialog1.InitialDir := path;
  if OpenDialog1.Execute then
    NomFitxer := OpenDialog1.FileName;
  if NomFitxer <> '' then
  begin
    aStream := TMemoryStream.create;
    Params := TMemoryStream.Create;
    idHTTP1.Request.ContentType := 'multipart/form-data;boundary=-----------------------------7cf87224d2020a';
    IdHTTP1.Request.Username := codi;
    IdHTTP1.Request.Password := password;
    try
      S := '-----------------------------7cf87224d2020a' + CRLF +
            'Content-Disposition: form-data; name="registro";          filename="'+
            RightStr(NomFitxer,14)+'"' + //registro es el nombre del campo del formulario html
            CRLF + 'Content-Type: text/plain' + CRLF + CRLF;
      Params.Write(S[1], Length(S));
      //copiamos contenido del fichero al memory stream "params"
      AssignFile(F,NomFitxer);
      Append(F);
      Reset(F);
      while not EOF(F) do
      begin
        readln(F, linea);
        if not EOF(F) then
          linea := linea + CRLF;
        Params.Write(linea[1],Length(linea));
      end;
      CloseFile(F);
      S := CRLF +
           '-----------------------------7cf87224d2020a';
      Params.Write(S[1], Length(S));
      try
        idHTTP1.Post('https:// ... --aqui va a web--', Params,aStream);
      except
        on E: Exception do
          showmessage('Error encountered during POST: ' + E.Message);
      end;
      aStream.SaveToFile(path+'\result.htm');
      aStream.WriteBuffer(#0' ', 1);
      showmessage(PChar(aStream.Memory));
    except
    end;
  end;
end;
__________________
Juan Antonio Castillo Hernández (jachguate)
Guía de Estilo | Etiqueta CODE | Búsca antes de preguntar | blog de jachguate

Última edición por jachguate fecha: 22-04-2004 a las 18:17:58.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 22:36:37.


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