火車頭發(fā)布接口發(fā)布的縮略圖是遠(yuǎn)程的圖片鏈接地址, 請(qǐng)問怎么把圖片遠(yuǎn)程下載下來 通過手工發(fā)布可以選擇遠(yuǎn)程下載

下面是接口代碼
if ($_GET['action'] == 'category') {
// 顯示欄目
foreach ($this->module['category'] as $t) {
if ($t['child'] == 0 && $t['tid'] == 1) {
echo '<h1>'.$t['name'].'<=>'.$t['id'].'</h1>'.PHP_EOL;
}
}
} else {
// 入庫(kù)數(shù)據(jù)
$data = $_REQUEST;
// 發(fā)布者id 1
$data['uid'] = 1;
// 發(fā)布者賬號(hào) admin
//$data['author'] = 'linlea';
// 主表字段
$fields[1] = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR));
$cache = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_category_data'));
$cache && $fields[1] = array_merge($fields[1], $cache);
// 附表字段
$fields[0] = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_data_0'));
$cache = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_category_data_0'));
$cache && $fields[0] = array_merge($fields[0], $cache);
// 去重復(fù)
$fields[0] = array_unique($fields[0]);
$fields[1] = array_unique($fields[1]);
$save = [];
// 主表附表歸類
foreach ($fields as $ismain => $field) {
foreach ($field as $name) {
isset($data[$name]) && $save[$ismain][$name] = $data[$name];
}
}
if (!$data['catid']) {
exit('欄目為空');
}
$save[1]['uid'] = $save[0]['uid'] = $data['uid'];
$save[1]['catid'] = $save[0]['catid'] = $data['catid'];
$save[1]['url'] = '';
$save[1]['status'] = 1; //9表示正常發(fā)布,1表示審核里面
$save[1]['hits'] = 0;
$save[1]['displayorder'] = 0;
$save[1]['link_id'] = 0;
$save[1]['comments'] = 0;
$save[1]['avgsort'] = 0;
$save[1]['inputtime'] = $save[1]['updatetime'] = SYS_TIME + rand(0, 7200);
$save[1]['inputip'] = '127.0.0.1';
$save[1]['price_quantity'] = 600;
// 驗(yàn)證標(biāo)題重復(fù)
if ($this->content_model->table(SITE_ID.'_'.MOD_DIR)->where('title', $save[1]['title'])->counts()) {
echo '重復(fù)';exit;
}
$rt = $this->content_model->save(0, $save);
if ($rt['code']) {
exit('成功');
} else {
exit('失敗');
}
}
exit;
最好的方法用火車頭軟件直接把圖片本地化了
開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
回復(fù)迅??蚣軇?chuàng)始人 我圖片是使用的阿里云oos所以不能用火車頭本地化
火車頭可以把附件儲(chǔ)存到阿里云,有插件
回復(fù)@張明宇 火車頭里沒找到相關(guān)插件
// 下載遠(yuǎn)程文件 $rt = \Phpcmf\Service::L('upload')->down_file([ 'url' => $file_url, 'attachment' => [], ]); if ($rt['code']) { // 附件歸檔 $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data']); $save[1]['文件字段'] = $att['code']; }領(lǐng)獎(jiǎng)勵(lì),不會(huì)可以私聊我
回復(fù)@易學(xué)習(xí) 好,成功必獎(jiǎng)勵(lì)
非常不錯(cuò),代碼和思路都很完美
回復(fù)@易學(xué)習(xí)
開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!