$uptypes=array('image/jpg','image/jpeg','image/png','image/pjpeg','image/gif','image/bmp','application/x-shockwave -flash','image/x-png');
$max_file_size=5000000; //Upload file size limit, unit BYTE
$addtime=date("Ymd",time());
$testdir="./".$addtime."/";
if(file_exists($testdir)):
else:
mkdir($testdir,0777);
endif;
$destination_folder=$addtime."/"; //Upload file path
$imgpreview=1; //Whether to generate a preview image (1 is generated, others are not generated);
$imgpreviewsize=1 /2; //Thumbnail ratio
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (!is_uploaded_file($_FILES["Pic"][tmp_name]))
//Whether the file exists
{
echo "File does not exist!";
exit;
}
$file = $_FILES["Pic"];
if($max_file_size < $file["size"])
//Check the file size
{
echo "< font color='red'>The file is too large! ";
exit;
}
if(!in_array($file["type"], $uptypes))
//Check file type
{
echo " can only be uploaded Image file or Flash! ";
exit;
}
if(!file_exists($destination_folder))
mkdir($destination_folder);
$filename=$file["tmp_name"];
$image_size = getimagesize($filename);
$pinfo=pathinfo($file["name"]);
$ftype=$ pinfo[extension];
$PicName = time().".".$ftype;
$destination = $destination_folder.$PicName;
if (file_exists($destination) && $overwrite != true)
{
echo "The file with the same name already exists!";
exit;
}
if(!move_uploaded_file ($filename, $destination))
{
echo "Error uploading file!";
exit;
}
$pinfo=pathinfo($destination);
$fname=$pinfo[basename];
}
?>
$path = dirname(__FILE__);
require_once($path.'/../../Module/Factory.php');
$Factory = new Factory();
$BLL_Trade = $Factory->FactoryTrade();
try {
$Infor = new Infor();
$Infor-> Title = $_POST['Title'];
$Infor->Deposit = $_POST['Deposit'];
$Infor->Hire = $_POST['Hire'];
$ Infor->Location = $_POST['Location'];
$Infor->Pic = $destination;
$Infor->Intro = $_POST['Intro'];
if( $_SESSION['MemberId'] ==''){
$Infor->Member->ID='';
}else {
$Infor->Member->ID = $_SESSION['MemberId'];}
if($_POST['GoodsBarCode'] ==''){
$Infor->Goods->BarCode = 0;
}else {
$Infor->Goods->BarCode = $_POST['GoodsBarCode'];}
$Infor->Class->ID = 0;//Modify in the future
$Infor-> IssueTime = time();
$Infor->ViewNum = 0;
$Infor->State = 1;//Undecided now, will be modified in the future
$Infor->Top = 0;
$Infor->Recommend = 0;
$Infor->BookMember->ID = 0;
$Infor->BookTime = 0;
$Infor->BookRemark = 0 ;
$BLL_Trade->CreateInfor($Infor);
echo 'Publish information successfully! ';
}
catch (Exception $Err){
echo $Err->getMessage();
}
?>