Created
June 14, 2017 02:27
-
-
Save shierw/328d6e014296ddecb1c669920ea13283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$uploadUrl = 'http://test.com/upload.php'; | |
// 转发从其它客户端上传的文件,name="file" | |
upload_file($uploadUrl, realpath($_FILES['file']['tmp_name']), $_FILES['file']['type'], $_FILES['file']['name']); | |
/** | |
* curl上传文件 | |
*/ | |
function upload_file($url, $path, $type, $filename){ | |
$data = array( | |
'adviceimg'=>'@'.$path.';type='.$type.';filename='.$filename, | |
); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_POST, true ); | |
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$return_data = curl_exec($ch); | |
curl_close($ch); | |
echo $return_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment