Delphi Upload Image - not working

Closed Posted Sep 15, 2010 Paid on delivery
Closed Paid on delivery

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

Project ID: #796601

About the project

6 proposals Remote project Active Oct 20, 2010

6 freelancers are bidding on average $124 for this job

AlosDeveloper

Hello, please check PMB

$500 USD in 5 days
(25 Reviews)
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 More

$30 USD in 3 days
(2 Reviews)
4.2
Blindfold

Please see PMB

$30 USD in 0 days
(8 Reviews)
3.5
charlie2002

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

$30 USD in 0 days
(3 Reviews)
3.5
Pandaweb

Hi, Please see PM.

$30 USD in 1 day
(1 Review)
1.8
AndrwProjects

Hi, check message.

$125 USD in 5 days
(1 Review)
0.9