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
  #2  
Antiguo 22-04-2004
tetemusic tetemusic is offline
Registrado
 
Registrado: abr 2004
Posts: 3
Poder: 0
tetemusic Va por buen camino
Problema solucionado!

Con el objeto idHTTP he conseguido hacerlo. Aqui os pongo el código, por si os es útil:

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;

Última edición por tetemusic fecha: 22-04-2004 a las 16:03:28.
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 23:30:18.


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