<?php
header('Content-Type:text/html;charset=utf-8');
$conf_basedir = "../"; //相对主目录的位置
$conf_where = "admin"; //选择调用相应模块
include_once($conf_basedir . "/base.inc.php");

if (isset($_POST["PHPSESSID"])) {
	session_id($_POST["PHPSESSID"]);
}
	if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
		echo "There was a problem with the upload";
		exit(0);
	} else {
		$uf = new UploadFile("Filedata");
		$uf->setFileType("jpg|gif|png|swf|css|doc|xls");
		$uf->setMaxSize("2048");
		$uf->setUploadType("ftp");
		$uf->setSaveDir("/njhouse/");
		$uf->setWatermark(true);
		$uf->setWatermarkType(1);
		$uf->setWatermarkPosition("rb");
		$uf->setWatermarkString("HOUSE365.COM");

		$uf->setImageCut(true);
		$uf->setImageWidth(660);
		$uf->setImageHeight(450);


		$uf->setResizeImage(true);
		$uf->setResizeWidth(140);
		$uf->setResizeHeight(105);
		if($uf->upload()=="success")
		{
			 $picurl =  $uf->getResizeImageURL();//缩略图片地址
			 $q = "INSERT INTO house_upload_provisional (`filename` ,`dateline` )VALUES ('$picurl', '".date('Y-m-d')."')";
			 $rs = $db->Execute($q);
			 if($rs) $id = $db->_insertid();//自增的用法

		} else {
			 die("<script>alert('未知错误，文件上传失败！');</script>");
		}

		echo $picurl."?pid=".$id;
	}

?>