query("SELECT attachment, filename,productid FROM {$tablepre}attachments WHERE aid='$aid'");
if ($query) {
$btfile=$db->fetch_array($query);
$btfileext = $btfile['filename'];
$btfilename = $btfile['attachment'];
$productid = $btfile['productid'];
}
else {
//echo 'database_error';
showmessage("很抱歉,你所阅读的附件无法从数据库读取,请确定该附件是否已经上传!","index.php");
}
if (strlen($btfilename) == 0 ) {
//echo '很抱歉,你所阅读的附件不存在,可能已经被删除!';
showmessage("很抱歉,你所阅读的附件不存在,可能已经被删除!","index.php");
}
if($productid == 0){
$url = "http://upload.docin.com/uploaddoc";
$data = array(
"Filedata" => "@"."f:/freehost/discuz1/web/bbs/attachments/".$btfilename, //修改f:/freehost/discuz1/web/bbs/attachments/ 为自己的地址
"title" => $btfileext,
"desc" => "bbbb",
"pcatid" => "5",
"catid" => "6",
"userId" => "10468_35809912",
"keyword" => "aaa"
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
if(strlen($result) != 0){
$db->query("update {$tablepre}attachments set productid={$result} WHERE aid='$aid'");
}
}else{
$result = $productid;
}
?>