上傳檔案func

2021-05-24 14:59:02 字數 1510 閱讀 6809

function up_file($file_dir=false,$input_name='',$file_type=array('image/gif','image/jpeg','image/pjpeg'),$file_name=false,$file_max_size=2)

$error_a = array('0: 沒有錯誤發生,檔案上傳成功。',

'1: 上傳的檔案超過了 php.ini 中 upload_max_filesize 選項限制的值。 ',

'2: 上傳檔案的大小超過了 html 表單中 max_file_size 選項指定的值。 ',

'3: 檔案只有部分被上傳。 ',

'4: 沒有檔案被上傳。' ,

'5: 上傳檔案為0',

'6: 找不到臨時資料夾。php 4.3.10 和 php 5.0.3 引進。'

); if (!file_exists($file_dir))

if (!is_array($file_type))

if ($input_name=='') $files = $_files;

else if(empty($_files[$input_name]) )

else $files = $_files[$input_name];

$re_array=array();

foreach( $files as $file)

if ($file["size"][$for_i] / 1048576 > $file_max_size)

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

型別禁止上傳!");

}$file_name = $file_name?$file_name:preg_replace('/^.+/.|^.+$/',md5(time()+count($re_array)).'.',$file['name'][$for_i]);

if (@move_uploaded_file($file["tmp_name"][$for_i],$file_dir.'/'.$file_name))

else }

}else

if ($file["size"] / 1048576 > $file_max_size)

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

型別禁止上傳!");

}$file_name = $file_name?$file_name:preg_replace('/^.+/.|^.+$/',md5(time()+count($re_array)).'.',$file['name']);

if (@move_uploaded_file($file["tmp_name"],$file_dir.'/'.$file_name))

else

}}if (count($re_array) == 0) return array(false,false);

return array(true,'上傳成功',$re_array);

}

函式指標,func與 func的區別

1.函式名,就是函式的首位址,那麼func與 func應該是不一樣的,偶然看到別人說兩種用法一樣,所以決定試一試。2.環境配置,vscode 模組 c c 0.29.0 編譯器 mingw,x86 64 8.1.0x86 64 8.1.0。3.如下 include include include v...

php mysql上傳檔案 PHP 檔案上傳

通過 php,可以把檔案上傳到伺服器。建立乙個檔案上傳表單 允許使用者從表單上傳檔案是非常有用的。請看下面這個供上傳檔案的 html 表單 芝麻教程 web3.xin 檔名 將以上 儲存到 form.html 檔案中。有關上面的 html 表單的一些注意項列舉如下 標籤的 enctype 屬性規定了...

檔案上傳和多檔案上傳

上傳檔案分析 上傳的檔案是以二進位制的形式上傳,因此在上傳表單裡面需要宣告enctype multipart form data 上傳的檔案所有的資訊都包含到全域性變數 files中 如 問題 1 上傳中文亂碼問題 只需使用函式incov 原來的編碼utf 8 轉化為的編碼gbk gb2312 檔名...