Luciano Veneziano
-
Content Count
3 -
Joined
-
Last visited
Posts posted by Luciano Veneziano
-
-
Hi everyone I have a PHP file that uploads images to me.
I should send with HTTPS and post the parameters from Delphi like this.<form action = "UPLOAD.PHP" enctype = "multipart / form-data">
<input type = "file" name = "upfile" required />
<input type = "submit" value = "Upload" />
</form>Unfortunately I'm not very good, I was able to make calls in https and post, but I could not set up idHTTP correctly
Has anyone already encountered this problem?
Thanks to all.
-
Hello everyone.
I have installed P4D without problems,
When I compile an example everything is fine but when I launch it
it asks me for a different version of the python dll.
Where can I change the version in Python components?
Thank you all
Upload files from Delphi to PHP
in Network, Cloud and Web
Posted · Edited by Luciano Veneziano
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);
?>