4
Following previous question:
Previous question on the same subject.
Now what he’s showing is:
http/1.1 404 Not Found.
Code used:
Functional in VCL:
function TForm1.UploadArquivo(server, script, caminhoarq : string) : boolean;
var
Response, UploadURL : String;
HTTPClient : TIdHTTP;
Lista : TIdMultiPartFormDataStream;
begin
result := False;
UploadURL := server + script;
HTTPClient := TIdHTTP.Create;
Lista := TIdMultiPartFormDataStream.Create;
HTTPClient.ReadTimeout := 10000;
HTTPClient.ProtocolVersion := pv1_1;
HTTPClient.Request.ContentType := 'utf-8';
HTTPClient.Request.UserAgent := 'Mozilla/3.0 (compatible;Indy Library)';
HTTPClient.HTTPOptions := [hoForceEncodeParams,hoKeepOrigProtocol];
Response := '';
try
try
//Lista.Add('Arquivo='+ caminhoarq);
Lista.AddFile('Arquivo', caminhoarq, 'application/octet-stream');
Response := UTF8Decode(Trim(HTTPClient.Post(UploadURL, Lista)));
//Label1.Text := Response;
if Response = 'OK' then
Result := true;
except
on e : exception do ShowMessage('Erro ao enviar arquivo ao servidor! Detalhes: '+e.Message);
end;
finally
Lista.Free;
HTTPClient.free;
end;
end;
However, the site exists, and I checked the string several times, and yet, it keeps presenting this message.
Now I’m testing in firemonkey, the same code, because I believe that has not changed much, or even nothing.
Does anyone have any idea what’s going on?
------------------EDIT-----------------------
According to the debugs I’ve been performing, follow the comments:
On this line, the code for:
Response := UTF8Decode(Trim(HTTPClient.Post(UploadURL, Lista)));
So I went deeper. In function DoRequest
.
When trying to connect with Host, in function CheckAndConnect
, which is situated within the function ConnectToHost
it returns the 404 error in Response
.
But when I try to do the same in a VCL form. It works perfectly.
Post the codes so we can see!
– Junior Moreira
Those are the ones on the link!
– Ramon Ruan
Good afternoon Ramon, I recommend you to make intuitive titles, the title of the two questions is practically the same and does not refer to the problem of the question.
– Guilherme Nascimento
@Guilhermenascimento, Good afternoon! I think that was the point, because everything is the same when I did for VCL, what changes is that the previous error is Solved, and the present only in FIREMONKEY.
– Ramon Ruan
@Guilhermenascimento no idea of what might be?
– Ramon Ruan
@Júniormoreira Some expensive idea?
– Ramon Ruan
@Ramonruan, do this, from a Breack in this line Response := Utf8decode(Trim(Httpclient.Post(Uploadurl, List)); put the mouse over it and see if it’s okay! If you write it down and put it here!
– Junior Moreira
I will post in the question the results.
– Ramon Ruan
@Júniormoreira follows comments on debug, to be more direct, he is returning the exception right away, while trying to perform the post.
– Ramon Ruan
I wanted you to give a breackpoint right there where I said Saka, put the mouse on, press F8 once, it will follow the line, put the mouse on the variable "Response" and see what she received!
– Junior Moreira
She gets nothing! precisely because of Error!
– Ramon Ruan
@Ramonruan, remove the Utf8decode that is going to Response, leave as you were using before, if it does not work, we will have to go to another approach!
– Junior Moreira
@Juniors, same thing!!
– Ramon Ruan
@Ramonruan, I’d have to see the whole project, it’s unfeasible for you to post the project here. If you want we can make contact outside the OS, when we arrive at a solution we post here!
– Junior Moreira
Thank you Junior!
– Ramon Ruan