//單上傳/*
* * @author buhuan
* @param string $file_form_name form表單的上傳檔案欄位的名稱 name屬性
* @param string $upload_path 上傳的資料夾絕對路徑
* @param string $web_path 上傳後檔案相對於**根目錄的相對路徑
* @param bool $debug 是否顯示上傳失敗的錯誤資訊
* @param array $file_type 上傳的檔案型別
* @param int $file_size_limit 上傳的檔案大小限制 預設512kb
* @return 失敗返回flase 或者 上傳成功返回位址的url */
function uploadimage($file_form_name='',$upload_path='',$web_path='',$debug=false,$file_size_limit=524288,$file_type
)
return
false
; }
//檢查字尾,如果不存在就取預設允許的字尾
//判斷目錄是否存在,不存在就建立
if(!is_dir($upload_path)) mkdir($upload_path,0777,true
);
$file = $_files[$file_form_name
];
//檢查檔案大小
$file_size = $file['size'];
if($file_size > $file_size_limit
)
return
false
; }
//檢查檔案型別
$type = $file['type'];
if(!in_array($type,$file_type
))
return
false
; }
//獲得字尾
$ext = explode('/',$type
);
//上傳後的檔名
$newfile = time().'.'.$ext[1];
if(move_uploaded_file($file['tmp_name'], $upload_path . $newfile
))
if($debug
)}
使用
html:class="txt">code:
//定義上傳的路徑
$upload_path = discuz_root.'data/attachment/plugin/vote/';
$web_path = 'data/attachment/plugin/vote/';
uploadimage('image',$upload_path,$web_path);
GitHub上傳自己的專案
1 準備 github帳號 安裝git 向github帳號中新增本機的ssh公匙 2 確保 已經提交到本地倉庫 cd projectname cd 到工程目錄下 git add git commit a m 說明 3 關聯遠端倉庫到本地 若無遠端倉庫,前往github,或者oschina建立之 gi...
Verdaccio上傳自己的私庫
1 編寫自己的第乙個庫 建立helloworld目錄 建立index.js並寫入 module.exports.hello function name 執行npm init生成package.json 我沒做修改,都用了預設的 author license isc 2 發布自己的第乙個庫 開啟命令列...
gitlab上傳自己的專案
1.gitlab上新建專案 2.找到要上傳的專案 3.初始化 會生成乙個.git檔案 git init4.將本地和伺服器上的git鏈結 git remote add origin 這裡是gitlab上剛建立的專案檔案的位址鏈結 origin後面空格 跟上想要提交的倉庫位址 4.將專案新增到倉庫中 g...