Skip to content

Instantly share code, notes, and snippets.

@girvan
Created March 22, 2012 03:43
Show Gist options
  • Save girvan/2155481 to your computer and use it in GitHub Desktop.
Save girvan/2155481 to your computer and use it in GitHub Desktop.
<?php
//----------------------------- custom block -------------------------
//檢查檔案大小
$size=0;
if(is_array($_FILES))
foreach($_FILES as $key=>$file){
$ext = substr($file['name'],-4);
$m = substr(md5($file['name']),0,3);
$name=date(YmdHis).$m.$ext; //給定你想要的檔案名稱
$_FILES[$key]['name'] = $name;
$size+=$file['size'];
}
if($size>1024*1024*2){
require_once dirname(__FILE__).'/io.php';
SendUploadResults('1','','','檔案太大了,請小於1MB');
}
// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/userfiles/'.$user_id.'/' ; //和網域的相對路徑
// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Useful if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
// $Config['UserFilesAbsolutePath'] ='/home/www/project/userfiles/'.$user_id.'/' ; //完整存檔路徑
//看起來是兩邊都要設定,一個是相對路徑,一個是絕對路徑。
//----------------------------- /custom block -----------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment