“@/path/to/a/file” in PHP, what does it mean?

前端 未结 3 1770
遥遥无期
遥遥无期 2021-01-27 17:02

I have stumbled to following code example:

$image = \'file/path\';
$code = $tmhOAuth->request(\'POST\', \'https://upload.twitter.com/1/statuses/update_with_me         


        
3条回答
  •  一生所求
    2021-01-27 17:56

    I don't know what library you're using, but I assume it uses the PHP cURL extension internally, because that's how you specify to cURL the path to a file that you want to upload, i.e., by prepending the path with an @. See this example from the PHP manual:

     'Foo', 'file' => '@/home/user/test.png');
    
    curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    
    curl_exec($ch);
    

提交回复
热议问题