<small id='Gcymk'></small><noframes id='Gcymk'>

    <i id='Gcymk'><tr id='Gcymk'><dt id='Gcymk'><q id='Gcymk'><span id='Gcymk'><b id='Gcymk'><form id='Gcymk'><ins id='Gcymk'></ins><ul id='Gcymk'></ul><sub id='Gcymk'></sub></form><legend id='Gcymk'></legend><bdo id='Gcymk'><pre id='Gcymk'><center id='Gcymk'></center></pre></bdo></b><th id='Gcymk'></th></span></q></dt></tr></i><div id='Gcymk'><tfoot id='Gcymk'></tfoot><dl id='Gcymk'><fieldset id='Gcymk'></fieldset></dl></div>

    1. <tfoot id='Gcymk'></tfoot>

      • <bdo id='Gcymk'></bdo><ul id='Gcymk'></ul>

        <legend id='Gcymk'><style id='Gcymk'><dir id='Gcymk'><q id='Gcymk'></q></dir></style></legend>

        HTML 上传 MAX_FILE_SIZE 似乎不起作用

        时间:2023-05-20

        <small id='zrtdR'></small><noframes id='zrtdR'>

        <tfoot id='zrtdR'></tfoot>

                <tbody id='zrtdR'></tbody>
                • <bdo id='zrtdR'></bdo><ul id='zrtdR'></ul>
                  <legend id='zrtdR'><style id='zrtdR'><dir id='zrtdR'><q id='zrtdR'></q></dir></style></legend>

                  <i id='zrtdR'><tr id='zrtdR'><dt id='zrtdR'><q id='zrtdR'><span id='zrtdR'><b id='zrtdR'><form id='zrtdR'><ins id='zrtdR'></ins><ul id='zrtdR'></ul><sub id='zrtdR'></sub></form><legend id='zrtdR'></legend><bdo id='zrtdR'><pre id='zrtdR'><center id='zrtdR'></center></pre></bdo></b><th id='zrtdR'></th></span></q></dt></tr></i><div id='zrtdR'><tfoot id='zrtdR'></tfoot><dl id='zrtdR'><fieldset id='zrtdR'></fieldset></dl></div>
                  本文介绍了HTML 上传 MAX_FILE_SIZE 似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想知道名为 MAX_FILE_SIZE 的隐藏字段应该如何工作?

                  I am wondering how is the hidden field named MAX_FILE_SIZE supposed to work?

                  <form action="" method="post" enctype="multipart/form-data">
                      <!-- in byes must preceed file field -->
                      <input type="hidden" name="MAX_FILE_SIZE" value="2097152" /> 
                      <input type="file" name="upload" />
                  
                      <input type="submit" name="submit" value="Submit" />
                  </form>
                  

                  我上传了一个 4MB 以上的文件,但我没有收到来自客户端的警告(我不是在谈论服务器端).MAX_FILE_SIZE 应该做什么?

                  I uploaded a 4MB+ file but I got no warning from client side (I am not talking about server side). What is it MAX_FILE_SIZE supposed to do?

                  更新

                  好的,所以 PHP 强加了一个软"限制.但是使用它和检查诸如 $_FILES['upload']['size'] < 之类的东西有什么区别吗?2000 在代码中?

                  OK so its for PHP to impose a "soft" limit. But is there any difference between using it and checking something like $_FILES['upload']['size'] < 2000 in code?

                  推荐答案

                  MAX_FILE_SIZEKB 而不是 字节.你是对的,它以字节为单位.因此,对于 4MB 以字节为单位转换 4MB {1024 * (1024 * 4)} 的限制,请尝试:

                  MAX_FILE_SIZE is in KB not bytes. You were right, it is in bytes. So, for a limit of 4MB convert 4MB in bytes {1024 * (1024 * 4)} try:

                  <input type="hidden" name="MAX_FILE_SIZE" value="4194304" /> 
                  

                  正如其他人所解释的那样,您永远不会收到警告.它只是在服务器端强加一个软限制.

                  As explained by others, you will never get a warning for this. It's there just to impose a soft limit on server side.

                  回答您的子问题.是的,有区别,您永远不要相信用户输入.如果您想始终施加限制,则必须始终检查其大小.不要相信 MAX_FILE_SIZE 的作用,因为它可以由用户更改.所以,是的,您应该检查以确保它始终达到或超过您想要的尺寸.

                  To answer your sub-question. Yes, there is a difference, you NEVER trust the user input. If you want to always impose a limit, you always must check its size. Don't trust what MAX_FILE_SIZE does, because it can be changed by a user. So, yes, you should check to make sure it's always up to or above the size you want it to be.

                  不同之处在于,如果您将 MAX_FILE_SIZE 强加为 2MB,并且用户尝试上传 4MB 的文件,一旦达到大约上传的前 2MB,传输将终止,PHP 将停止接受该文件的更多数据.它将报告文件数组的错误.

                  The difference is that if you have imposed a MAX_FILE_SIZE of 2MB and the user tries to upload a 4MB file, once they reach roughly the first 2MB of upload, the transfer will terminate and the PHP will stop accepting more data for that file. It will report the error on the files array.

                  这篇关于HTML 上传 MAX_FILE_SIZE 似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:设置 PHP tmp 目录 - PHP 上传不起作用 下一篇:在服务器端处理 plupload 的分块上传

                  相关文章

                  最新文章

                  <legend id='J5Yog'><style id='J5Yog'><dir id='J5Yog'><q id='J5Yog'></q></dir></style></legend>

                  • <bdo id='J5Yog'></bdo><ul id='J5Yog'></ul>

                  1. <small id='J5Yog'></small><noframes id='J5Yog'>

                  2. <i id='J5Yog'><tr id='J5Yog'><dt id='J5Yog'><q id='J5Yog'><span id='J5Yog'><b id='J5Yog'><form id='J5Yog'><ins id='J5Yog'></ins><ul id='J5Yog'></ul><sub id='J5Yog'></sub></form><legend id='J5Yog'></legend><bdo id='J5Yog'><pre id='J5Yog'><center id='J5Yog'></center></pre></bdo></b><th id='J5Yog'></th></span></q></dt></tr></i><div id='J5Yog'><tfoot id='J5Yog'></tfoot><dl id='J5Yog'><fieldset id='J5Yog'></fieldset></dl></div>

                      <tfoot id='J5Yog'></tfoot>