06-24-2026, 07:12 AM
Your PHP script only processes the upload when this condition is true:
php
if (isset($_POST['upload'])) {
In your HTML form, the submit button sends a field named `upload`:
html
<button type="submit" name="upload">Upload image</button>
However, in your Delphi code you're only posting the file:
delphi
PostData.AddFile('image', FFileToUpload);
There is no `upload` field being sent, so `isset($_POST['upload'])` is false and none of the upload code executes.
Try adding the missing form field:
delphi
PostData.AddFormField('upload', '1');
PostData.AddFile('image', FFileToUpload);
Also, your PHP script does not output anything. It redirects using `header("Location: ...")`, so if the upload succeeds you'll receive a redirect response rather than page content. Check:
delphi
HttpResponse.StatusCode
HttpResponse.Location
or inspect the final URL after redirects.
Additionally, make sure the field name matches exactly:
php
$_FILES['image']
so the Delphi code must use:
delphi
PostData.AddFile('image', FFileToUpload);
which you are already doing correctly.
php
if (isset($_POST['upload'])) {
In your HTML form, the submit button sends a field named `upload`:
html
<button type="submit" name="upload">Upload image</button>
However, in your Delphi code you're only posting the file:
delphi
PostData.AddFile('image', FFileToUpload);
There is no `upload` field being sent, so `isset($_POST['upload'])` is false and none of the upload code executes.
Try adding the missing form field:
delphi
PostData.AddFormField('upload', '1');
PostData.AddFile('image', FFileToUpload);
Also, your PHP script does not output anything. It redirects using `header("Location: ...")`, so if the upload succeeds you'll receive a redirect response rather than page content. Check:
delphi
HttpResponse.StatusCode
HttpResponse.Location
or inspect the final URL after redirects.
Additionally, make sure the field name matches exactly:
php
$_FILES['image']
so the Delphi code must use:
delphi
PostData.AddFile('image', FFileToUpload);
which you are already doing correctly.

