<?session_start (); if ($_session[' company ']== ') { //exit ();}? ><?php//Upload images $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])// Is there a file { echo "<font color= ' Red ' > file does not exist! </font> "; exit;} $file = $_files["Pic"];if ($max _file_size < $file ["size"])//Check file size {echo "<font color= ' Red ' > file too large! </font> ";exit; } if (!iN_array ($file ["type"], $uptypes)//Check file type {echo "<font color= ' red ' > can only upload image files or flash! </font> "; 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 "<font color= ' red ' > the same name file already exists! </a> "; exit;} if (!move_uploaded_file ($filename, $destination)) { echo "<font color= ' red ' > upload file Error! </a> "; 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;//Modified $infor->issuetime = time (), $Infor->viewnum = 0; $Infor->state = 1;//now undecided, Modify $infor->top = 0 later, $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 ();}? >
Uploading files to a new folder