×


Sending a multipart/form-data or file upload from PHP server side to remote URL

Requirement to send Form data/file to another external API from A PHP server ?. Imagine a story to upload an image to an external file upload API from a PHP server( Can be a CMS like  WordPress).

This task can be achieved using CURL. PHP now has a class CurlFile which is now is available in the PHP versions PHP 5 >= 5.5.0, PHP 7. The following is the snippet to use CurlFile.

 

You can use Ajax to get the file and send it using the above code. Modify the code to handle the errors and line

should be avoided in production as SSL verification is ignored with this option.

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *