forked from HANYANG/HANYANG_MES
72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
class Sk_Attach extends Attach {
|
|
function __construct( $table ){
|
|
parent::__construct($table);
|
|
}
|
|
|
|
public function putAttach( $upfile, $gubun, $nid, $sid, $exp="" ) {
|
|
$target_dir = _UP_PATH_."/{$gubun}";
|
|
if( !file_exists($target_dir) ){
|
|
mkdir($target_dir);
|
|
}
|
|
$rst = move_uploaded_file($upfile['tmp_name'], "{$target_dir}/{$nid}_{$sid}.dat");
|
|
if( !$rst ) return false;
|
|
|
|
if( strpos($upfile['type'], "image") !== false ){
|
|
$iinfo = getimagesize("{$target_dir}/{$nid}_{$sid}.dat");
|
|
$upfile['width'] = $iinfo[0];
|
|
$upfile['height'] = $iinfo[1];
|
|
}
|
|
|
|
$sqldata = Array(
|
|
"gubun" => $gubun?:"",
|
|
"nid" => $nid?:"",
|
|
"sid" => $sid?:"",
|
|
"file_name" => $upfile['name']?:"",
|
|
"file_size" => $upfile['size']?:0,
|
|
"file_type" => $upfile['type']?:"",
|
|
"file_width" => $upfile['width']?:"",
|
|
"file_height" => $upfile['height']?:"",
|
|
"file_exp" => $exp,
|
|
"reg_date" => $this->DB->sqleval("getdate()"),
|
|
);
|
|
|
|
return $this->putData( $sqldata );
|
|
}
|
|
|
|
public function setAttach( $upfile, $gubun, $nid, $sid, $exp="" ) {
|
|
$target_dir = _UP_PATH_."/{$gubun}";
|
|
if( !file_exists($target_dir) ){
|
|
mkdir($target_dir);
|
|
}
|
|
$rst = move_uploaded_file($upfile['tmp_name'], "{$target_dir}/{$nid}_{$sid}.dat");
|
|
if( !$rst ) return false;
|
|
|
|
if( strpos($upfile['type'], "image") !== false ){
|
|
$iinfo = getimagesize("{$target_dir}/{$nid}_{$sid}.dat");
|
|
$upfile['width'] = $iinfo[0];
|
|
$upfile['height'] = $iinfo[1];
|
|
}
|
|
|
|
$sqldata = Array(
|
|
"gubun" => $gubun?:"",
|
|
"nid" => $nid?:"",
|
|
"sid" => $sid?:"",
|
|
"file_name" => $upfile['name']?:"",
|
|
"file_size" => $upfile['size']?:0,
|
|
"file_type" => $upfile['type']?:"",
|
|
"file_width" => $upfile['width']?:"",
|
|
"file_height" => $upfile['height']?:"",
|
|
"file_exp" => $exp,
|
|
"reg_date" => $this->DB->sqleval("getdate()"),
|
|
);
|
|
|
|
$whererow = Array(
|
|
"gubun" => $gubun?:"",
|
|
"nid" => $nid?:"",
|
|
"sid" => $sid?:"",
|
|
);
|
|
|
|
return $this->setData( $sqldata, $whererow );
|
|
}
|
|
} |