Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
upload image with php file
#4
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.
Reply


Messages In This Thread
upload image with php file - by Madammar - 06-17-2020, 05:05 PM
RE: upload image with php file - by rlebeau - 06-17-2020, 07:24 PM
RE: upload image with php file - by Madammar - 06-18-2020, 04:50 AM
RE: upload image with php file - by patriciajboutin - 06-24-2026, 07:12 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)