You can not change this field because it is read-only because of security issues .
What you can do is submit the file separately using the Indy components, the TIdMultipartFormDataStream
and TIdHTTP
.
Uses
IdMultipartFormData, IdHTTP,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient;
//....
procedure EnviarArquivo(const URL, Campo, Arquivo: string);
var
IdHttp: TIdHTTP;
Parametros: TIdMultipartFormDataStream;
SS: TStringStream;
begin
IdHttp := TIdHTTP.Create(nil);
SS := TStringStream.Create();
try
Parametros := TIdMultipartFormDataStream.Create;
try
Parametros.AddFile(Campo, Arquivo);
try
IdHttp.Post(URL, Parametros, SS);
ShowMessage('Status: ' + IntToStr(IdHttp.ResponseCode));
except
on E: Exception do
ShowMessage('Post Error: ' + E.Message);
end;
Memo1.Text := SS.DataString;
finally
Parametros.Free;
end;
finally
IdHttp.Free;
SS.Free;
end;
end;
Use this:
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
EnviarArquivo('<URL>', 'attachmentElement', '<CaminhoDoArquivo>');
end;