开发者

upload file via curl [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I try to upload file via curl in php, this is my sample code

set_time_limit(0);
$url = 'http://localhost/curltest/upload.php';
$field_name = 'file'; 
if (isset($_FILES['file']))
{
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_POSTFIELDS,array("$field_name"=>"@".$_FILES['file']['tmp_name']));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
}

I set permission to 777,but i开发者_Python百科t doesn't work. where is the problem? (it doesn't show any result)


I think there is a problem here : $_FILES['file'['tmp_name'] it should be $_FILES['file']['tmp_name'] or something like this. You forget to close the ['file' bracket

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜