php 生成自動建立資料夾並上傳檔案

2021-04-23 14:25:04 字數 1742 閱讀 1712

<?

session_start();

if($_session['company']=='')

?><?php //上傳

$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')

$file = $_files["pic"];

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

//檢查檔案大小

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

//檢查檔案型別

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)

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

$pinfo=pathinfo($destination);

$fname=$pinfo[basename];

}?><?

$path = dirname(__file__);

require_once($path.'/../../module/factory.php');

$factory = new factory();

$bll_trade = $factory->factorytrade();

try else

if($_post['goodsbarcode'] =='')else

$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)

php自動建立資料夾並上傳檔案

複製 php檔案上傳功能 例項 php檔案上傳大小設定方法 php檔案上傳 大全 例項分享 php檔案上傳綜合例項分享 php 檔案上傳 普通上傳與非同步上傳 的例子 php 檔案上傳的例項解析 php 檔案上傳例項剖析 php單檔案上傳的例項分析 php多檔案上傳的簡單示例分析 php檔案上傳原理...

php 建立資料夾

function mkdirs dir if mkdir dir,0777 chmod dir,777 給目錄操作許可權 return true 開始時我認為,只要給乙個路徑,mkdir就可以建立資料夾,但是事實並不是那樣,單個的mkdir只能建立一級目錄,對於多級的就不行了。1.使用php5新增方...

C 自動建立資料夾

例項 include stdafx.h include include include include include using namespace std int tmain int argc,tchar argv return 0 執行結果是在.exe目錄下判斷123 1 2 3 是否有這些檔...