/** * 上传外链索引图片 */ public function upload_indexpic() { //外链索引图片 $material = parent::upload_indexpic(); if (!empty($material)) { $material['pic'] = json_encode(array('host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename'])); $this->addItem($material); } else { $return = array('error' => '文件上传失败'); $this->addItem($return); } $this->output(); }
/** * 上传外链索引图片 */ public function upload_indexpic() { //外链索引图片 $material = parent::upload_indexpic(); if (!empty($material) && is_array($material)) { $material['pic'] = array('host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename']); $data = array('material_id' => $material['id'], 'name' => $material['name'], 'pic' => serialize($material['pic']), 'host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename'], 'type' => $material['type'], 'mark' => $material['mark'], 'imgwidth' => $material['imgwidth'], 'imgheight' => $material['imgheight'], 'filesize' => $material['filesize'], 'create_time' => $material['create_time'], 'ip' => $material['ip'], 'remote_url' => $material['remote_url']); $this->obj->insert_data($data, 'material'); $material['filesize'] = hg_bytes_to_size($material['filesize']); $material['success'] = true; $material['material_id'] = $material['id']; $this->addItem($material); } else { $return = array('error' => '文件上传失败'); $this->addItem($return); } $this->output(); }
function upload_indexpic() { //外链索引图片 if (!$_FILES['indexpic']['error'] && is_array($_FILES['indexpic'])) { $material = parent::upload_indexpic(); if (!empty($material)) { /*$sql = "REPLACE INTO " . DB_PREFIX ."material SET "; $material['material_id'] = $material['id']; $material['pic'] = array( 'host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename'], ); $material['pic'] = serialize($material['pic']); unset($material['bundle_id'], $material['mid'], $material['id'], $material['url']); $sql_extra = $space =''; foreach($material as $k => $v) { $sql_extra .= $space . $k . "='" . $v . "'"; $space = ','; } $this->db->query($sql . $sql_extra); */ $material['filesize'] = hg_bytes_to_size($material['filesize']); $material['success'] = true; $material['id'] = $material['material_id']; $this->addItem($material); } else { $return = array('success' => false, 'error' => '文件上传失败'); $this->addItem($return); } } else { $return = array('success' => false, 'error' => '文件上传失败'); $this->addItem($return); } $this->output(); }