Copy CodeThe code is as follows:
Session_Start ();
if ($_session[' company ']== ')
{
Exit ();
}
?>
$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 map (1 is generated, others are not generated);
$imgpreviewsize =1/2; Thumbnail scale
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 File size
{
echo "file is too big! ";
Exit
}
if (!in_array ($file ["type"], $uptypes))
Check file types
{
echo "can only upload image files 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 "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;//later modified
$Infor->issuetime = time ();
$Infor->viewnum = 0;
$Infor->state = 1;//now undecided, later modified
$Infor->top = 0;
$Infor->recommend = 0;
$Infor->bookmember->id = 0;
$Infor->booktime = 0;
$Infor->bookremark = 0;
$BLL _trade->createinfor ($Infor);
Echo ' published the message successfully! ';
}
catch (Exception $Err) {
echo $Err->getmessage ();
}
?>