Delphi Upload Image - not working

Cerrado Publicado Sep 15, 2010 Pagado a la entrega
Cerrado Pagado a la entrega

I have a function that attempts to upload an image to a web form.. however it doesn't return any results. It certainly doesn't work.

First person to point out whats wrong with my function or fix it for me gets paid!

function [login to view URL](url: string; params, values: array of string; useragent: string; UseProxy:Integer; pHost, pPort, pUser, pPass:string) : string;

var

HTTP:THTTPSend;

Data:TMemoryStream;

ss:TStringStream;

stringData:String;

picdata:String;

NewUrl, Bound:String;

PostData: OleVariant;

n,i,idx: integer;

SL,CC,PICD:TStringList;

jpeg: TJPEGImage;

begin

Bound := '--------' + FormatDateTime('mmddyyhhnnsszzz', Now);

HTTP := [login to view URL];

[login to view URL] := 0;

[login to view URL](CookieStream);

try

[login to view URL] := useragent;

[login to view URL] := True;

[login to view URL] := '80';

[login to view URL] := url;

[login to view URL] :='1.1';

if UseProxy = 1 then begin

if (pUser <> '') and (pPass <> '') then begin

[login to view URL] := pHost;

[login to view URL] := pPort;

[login to view URL] := pUser;

[login to view URL] := pPass;

end else begin

[login to view URL] := pHost;

[login to view URL] := pPort;

[login to view URL] := '';

[login to view URL] := '';

end;

end;

stringData := '';

for i:= 0 to 6 do

begin

if i = 1 then begin

stringData := stringData + '--' + Bound + crlf + 'Content-Disposition: form-data; name="' + params[i] + '"' + crlf+crlf+ values[i] + crlf;

stringData := stringData + '--' + Bound + crlf +'Content-Disposition: form-data; name="pic"; filename="[login to view URL]"' + crlf;

stringData := stringData + 'Content-Type: image/jpeg'+crlf + crlf;

Data := [login to view URL];

[login to view URL]('c:\exx\[login to view URL]');

ss := [login to view URL]('') ;

[login to view URL](data, [login to view URL]);

stringData := stringData + [login to view URL];

[login to view URL];

[login to view URL];

end else begin

stringData := stringData + '--' + Bound + crlf + 'Content-Disposition: form-data; name="' + params[i] + '"' + crlf+crlf+ values[i] + crlf;

end;

end;

stringData := stringData + crlf + '--' + Bound + '--'+crlf; //FOOOOTER

//stringData := stringData + #0;

[login to view URL] := 'Content-Type: multipart/form-data; boundary=' + bound;

WriteStrToStream([login to view URL], stringData);

[login to view URL]('C:\[login to view URL]');

if [login to view URL]('POST',url) then begin

case [login to view URL] of

301, 302, 307: begin

n := FoundLocationStrNum([login to view URL]);

if (n >= 0) and (n <= [login to view URL]) then begin

NewUrl := StringReplace([login to view URL][n],'Location: ','',[]);

[login to view URL](newurl);

newurl := StringReplace(newurl, ':443', '',

[rfReplaceAll, rfIgnoreCase]);

[login to view URL](newurl);

[login to view URL];

[login to view URL]('GET',newurl);

end;

end;

end; //case

end else begin

doPostpic := '000';

[login to view URL];

exit;

end;

finally

//return

SL:=[login to view URL];

[login to view URL]([login to view URL]);

[login to view URL](CookieStream);

doPostpic := [login to view URL];

[login to view URL];

[login to view URL];

end;

end;

Delphi

Nº del proyecto: #796601

Sobre el proyecto

6 propuestas Proyecto remoto Activo Oct 20, 2010

6 freelancers están ofertando un promedio de $124 por este trabajo

AlosDeveloper

Hello, please check PMB

$500 USD en 5 días
(25 comentarios)
6.3
doi6

I managed to post data with your code and get result from a webpage. I am open to help you test your code and changes by opening a web port and analyzing the data sent. The suspicious things i found in your code were t Más

$30 USD en 3 días
(2 comentarios)
4.2
Blindfold

Please see PMB

$30 USD en 0 días
(8 comentarios)
3.5
charlie2002

Working example is in your PMB. Buy this code if you like.

$30 USD en 0 días
(3 comentarios)
3.5
Pandaweb

Hi, Please see PM.

$30 USD en 1 día
(1 comentario)
1.8
AndrwProjects

Hi, check message.

$125 USD en 5 días
(1 comentario)
0.9