I want to use a PHP as a proxy to upload files to server. How can i send the uploaded files to a se开发者_开发知识库rver together with Basic Authorization header?
Is PECL ssh2 an option? If it is, then you won't need the authentication header as you can do authentication through ssh. If not, then you can use cURL to set the header and send the information to a script on another server that is designed to receive the upload (and under the http authentication requirements).
Use cURL and Basic access authentication headers:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://example.com/path/");
curl_setopt($curl, CURLOPT_PORT , 80);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array('Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='));
cURL provides other options like CURLOPT_FILE
that can help your specific case.
精彩评论