public function updateImages() { foreach ($this->arrImageField as $k => $v) { if ($v['mode'] == 'thumb') { if (!isset($_FILES[$v['thumb_source']])) { continue; } $f = $_FILES[$v['thumb_source']]; if ($f['error'] == UPLOAD_ERR_NO_FILE) { continue; } // if ($f['error'] != 0) { throw new Exception("JTable::updateImages error!({$k})"); } $source_fpath = $this->arrImageField[$v['thumb_source']]['target_fpath']; $fext = JWStdio::fileExtension($source_fpath); $target_url = "{$_SERVER['JASONWANG826_CONFIG']['SYSFILE_ALIAS']}{$v['tdir']}/{$v['prefix']}.{$this->data['id']}.{$fext}"; $target_fpath = JWStdio::URLfpath($target_url); copy($source_fpath, $target_fpath); JWStdio::imageResize($target_fpath, $v['width'], $v['height']); } else { if (!isset($_FILES[$k])) { continue; } $f = $_FILES[$k]; if ($f['error'] == UPLOAD_ERR_NO_FILE) { continue; } // if ($f['error'] != 0) { throw new Exception("JTable::updateImages error!({$k})"); } // remove org file if (isset($this->data[$k]) && !empty($this->data[$k])) { JWStdio::URLDelete($this->data[$k]); } $fext = JWStdio::fileExtension($f['name']); $target_url = "{$_SERVER['JASONWANG826_CONFIG']['SYSFILE_ALIAS']}{$v['tdir']}/{$v['prefix']}.{$this->data['id']}.{$fext}"; $target_fpath = JWStdio::URLfpath($target_url); JWStdio::moveUploadFile($f['tmp_name'], $target_fpath); if ($v['mode'] == 'resize') { JWStdio::imageResize($target_fpath, $v['width'], $v['height']); } else { if ($v['mode'] == 'resize-by') { JWStdio::imageResize($target_fpath, $this->data[$v['width']], $this->data[$v['height']]); } else { if ($v['mode'] == 'file') { // file do nothing } else { throw new Exception("JTable::updateImages unsupported mode '{$v['mode']}'!({$k})"); } } } $this->arrImageField[$k]['target_fpath'] = $target_fpath; } $sql = "UPDATE `{$this->table}` SET\n\t\t\t\t\t\t`{$v['field']}`=:{$v['field']}\n\t\t\t\t\tWHERE `id`=:id;"; self::$db->doQuery($sql, array('id' => $this->data['id'], $v['field'] => $target_url)); } }
<? require_once( './local.inc' ); $f=apache_lookup_uri( $_GET['fpath'] )->filename; $filename=basename($f); $fname = iconv('utf-8','big5',$_GET['fname']).".".JWStdio::fileExtension($filename); header( "Content-Type: application/octet-stream" ); header( 'Content-Disposition: attachment; filename="' . $fname . '"' ); header( 'Pragma: no-cache' ); readfile( $f ); ?>