Recommended: "PHP Video Tutorial"

PHP crawler. When a new image is detected, it needs to be uploaded to a cross-regional CDN back-to-origin server (static resource server). The person in charge of the server only provides an upload API.
PHP CURL new \CURLFile($path) Upload (disadvantage: IO operation)
Upload API √## as a binary file #
composer require ar414/curl-upload-binary-image
<?php require_once '../vendor/autoload.php'; use Ar414\UploadBinaryImage; $url = 'http://0.4.1.4:414/upload?path=/test/'; $fields = []; $fieldName = 'file'; $fileName = 'ar414.png'; $fileBody = file_get_contents('https://github.com/ar414-com/ar414-com/raw/master/assets/ar414.png'); $ret = UploadBinaryImage::upload($url,$fields,$fieldName,$fileName,$fileBody); var_dump($ret);
2.Through
postman, Google Chrome Upload the file to view the sent request data3. Splice the request body
set Body Block The above is the detailed content of About PHP CURL uploading binary stream images. For more information, please follow other related articles on the PHP Chinese website!