Reputation: 9104
I have a WebService that works that way:
I do it that way because I do not know how to make a web service that can receive a file by HTTP POST directly.
The server works under PHP & MySQL.
The client that sends the file and register it is made in Delphi. I use Indy now.
In the future I intend to make it full web but my client is still addicted to windows.
So, can I make a rest web service that receives a pdf file and also receive data about this file, like "from", "to", "description"...? How?
Upvotes: 0
Views: 1473
Reputation: 17203
In order to upload a file, you must perform a POST call to your WebService. (You can also perform a PUT operation, but that's not covered in this answer).
In php, you use the $_FILES associative array, which contains the items uploaded to the script using the mentioned POST method.
Once you accept the file, you use the move_uploaded_file function to save the file in your server disk, and then you can read the file from there and post it to a database or any other operation you want to perform.
I recommend you to read the referenced articles in the handling file uploads php manual entry.
You can also find a working example on the php file upload w3schools article.
There are various libraries that allow you to perform HTTP operations from Delphi. My preferred one is Indy Sockets, and you'll find a great number of questions (and answers) here on StackOverflow, for example: Http Post with indy which includes a flie attachment.
Upvotes: 1