php自动生成apk文件夹,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 "文件不存在!";

exit;

}

$file = $_FILES["Pic"];

if($max_file_size < $file["size"])

//检查文件大小

{

echo "文件太大!";

exit;

}

if(!in_array($file["type"], $uptypes))

//检查文件类型

{

echo "只能上传图像文件或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 "同名文件已经存在了!";

exit;

}

if(!move_uploaded_file ($filename, $destination))

{

echo "上传文件出错!";

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();

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值