コード例 #1
0
 function &_put($options = array())
 {
     $result = '';
     //$this->log(print_r($options, 1));
     $path = $options['url'];
     $url = 'http:/' . $options['path'];
     $result = http_post_file($url, $path);
     if (!$result) {
         throw new RuntimeException('Could not post file: ' . $url);
     }
     return $result;
 }
コード例 #2
0
ファイル: tietuku.func.php プロジェクト: 994724435/Ride
function tietuku_upload_file($filepath, $filename)
{
    global $conf;
    $token = $conf['tietuku_token'];
    $post_url = 'http://up.tietuku.com/';
    if (!is_file($filepath)) {
        return xn_error(-1, '文件不存在');
    } elseif (filesize($filepath) == 0) {
        return xn_error(-1, '文件大小为 0');
    }
    //$token = '00f47da319173e011683b6f4c63b46f8fe8a9471:ak9XYzQ5YmhIalIwYlNwMFJwaVB6Vm9XMFBjPQ==:eyJkZWFkbGluZSI6MTQ0MDY2MzkzOSwiYWN0aW9uIjoiZ2V0IiwidWlkIjoiNTgyNyIsImFpZCI6IjEyNzc5IiwiZnJvbSI6ImZpbGUifQ==';
    $postdata = array();
    $postdata['Token'] = $token;
    $postdata['file'] = curl_file_create($filepath, $filename);
    $s = http_post_file($post_url, $postdata);
    $arr = json_decode($s, 1);
    if (empty($arr) || empty($arr['size'])) {
        return xn_error(-3, '返回数据格式有问题:' . $s);
    }
    return $arr;
}