您好,登录后才能下订单哦!
本篇文章为大家展示了php中怎么自动生成创建文件夹,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
代码如下:
<?
session_start();
if($_SESSION['Company']=='')
{
//exit();
}
?><?php //上传图片
$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; //上传文件大小限制, 单位BYTE
$addtime=date("Ymd",time());
$testdir="./".$addtime."/";
if(file_exists($testdir)):
else:
mkdir($testdir,0777);
endif;
$destination_folder=$addtime."/"; //上传文件路径
$imgpreview=1; //是否生成预览图(1为生成,其他为不生成);
$imgpreviewsize=1/2; //缩略图比例
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (!is_uploaded_file($_FILES["Pic"][tmp_name]))
//是否存在文件
{
echo "<font color='red'>文件不存在!</font>";
exit;
}
$file = $_FILES["Pic"];
if($max_file_size < $file["size"])
//检查文件大小
{
echo "<font color='red'>文件太大!</font>";
exit;
}
if(!in_array($file["type"], $uptypes))
//检查文件类型
{
echo "<font color='red'>只能上传图像文件或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'>同名文件已经存在了!</a>";
exit;
}
if(!move_uploaded_file ($filename, $destination))
{
echo "<font color='red'>上传文件出错!</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;//日后修改
$Infor->IssueTime = time();
$Infor->ViewNum = 0;
$Infor->State = 1;//现在未定,日后修改
$Infor->Top = 0;
$Infor->Recommend = 0;
$Infor->BookMember->ID = 0;
$Infor->BookTime = 0;
$Infor->BookRemark = 0;
$BLL_Trade->CreateInfor($Infor);
echo '发布信息成功!';
}
catch (Exception $Err){
echo $Err->getMessage();
}
?>
上述内容就是php中怎么自动生成创建文件夹,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。