Funziona perfettamente:
function httpsUpload(URL : string; fname : String ) : String;
var
LRequest: THTTPClient;
LFormData: TMultipartFormData;
LResponse: TStringStream;
begin
LRequest := THTTPClient.Create;
LFormData := TMultipartFormData.Create();
LResponse := TStringStream.Create;
try
LFormData.AddField('json', '{"id":1,"user":"Luciano"}'); //optional
LFormData.AddFile('file', fname);
LRequest.Post(URL, LFormData, LResponse);
Result := LResponse.DataString;
finally
LFormData.Free;
LResponse.Free;
LRequest.Free;
end;
end;
phpfile
<?php
include_once("local/setup.php");
$where = $_FILES["file"]["name"];
if(move_uploaded_file($_FILES["file"]["tmp_name"], $where))
{
echo "OK\r\n";
}
else
{
echo "ERR\r\n";
}
print_r($_FILES);
?>