PHP アップローダを使用していて、特定のスクリプトで post_max_size と upload_max_filesize の php.ini のデフォルト値をオーバーライドする方法があるかどうか疑問に思っていましたか?
管理セクションでアップローダーの制限を大きくすることは問題ありませんが、パブリック セクションでそれほど大きな制限を加えたくないため、php.ini で全体的に変更したくありません。
.htaccess ファイルを介してこれを行うことができるはずです。管理領域に 10Mb のアップロードを許可し、公開側に 2 つ許可するとします。デフォルト値 (php.ini 内) を 2 Mb に設定し、管理領域で htaccess ファイルに追加します。
php_flag upload_max_filesize 10M
編集
これはディレクトリレベルで動作することを意図しています-管理ページはすべて、たとえば mydomain.com/admin/ から実行され、webroot (.htaccess ファイルを置く場所) に物理的な /admin フォルダーがあると想定しています
PHPのini_set関数を使ってみてください
この方法で php.ini ファイルのデフォルト値をオーバーライドできるはずです。ページ出力の前に呼び出すようにしてください。
Changing this value per user is not possible unless you write to an .htaccess file for every visit.
Why don't you simply allow the upload and discard it if it is too big?
I did find this but I don't trust it as HTML has no idea of what you are doing with that input.
EDIT: Basically, as Apache is what handles the actual physical transferring of the file, you need Apache to be aware of any limits before the user submits the form. As HTML has nothing to do with this, you can't set it there and as PHP is only helpful when the file is actually on the server, you need to check it after it has been uploaded. Sorry, I realised my first answer was a bit vague. Hope this helps a bit more.