Delphi Upload Image - not working
$30-250 USD
Dibayar saat pengiriman
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;
ID Proyek: #796601
Tentang proyek
6 freelancer rata-rata menawar $124 untuk pekerjaan ini
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 Lebih banyak