首页 文章

如何更改特定页面的最大上传大小?

提问于
浏览
0

好吧..说我有音乐服务,如何增加该特定页面的最大文件上传大小,以便在选择大文件时不会超时?

好的,我知道你可以通过更改来修补php.ini文件

memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M

,但那时全局设定 .

3 回答

  • 0

    您可能希望更改网站的最大上传文件大小 . 例如,您可以设置下限以防止用户将大型文件上传到您的站点 . 为此,请更改.htaccess文件中的upload_max_filesize和post_max_size指令 .

    要更改PHP脚本的最大上载文件大小,请按照下列步骤操作:

    Log in to your account using SSH.
    Use a text editor to add the following line to the .htaccess file. Replace xx with the maximum upload file size that you want to set, in megabytes:
    
    php_value upload_max_filesize xxM
    
    Add the following line to the .htaccess file. Replace xx with the maximum HTTP POST file size that you want to set, in megabytes:
    
    php_value post_max_size xxM
    

    将更改保存到.htaccess文件并退出文本编辑器 . 要验证新设置是否处于活动状态,请在.htaccess文件所在的同一目录中创建一个包含以下代码的PHP测试文件:

    在Web浏览器中加载测试文件,然后搜索该指令的名称 . “本地值”列应显示您在.htaccess文件中指定的新设置 .

    了解更多详情http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/

    要么

    <?php
    
    // Define file size limit
    $limit_size=50000;
    
      code......
    
    $file_size=$HTTP_POST_FILES['ufile']['size'];
    
    if($file_size >= $limit_size){
    echo "Your file size is over limit<BR>";
    echo "Your file size = ".$file_size;
    echo " K";
    echo "<BR>File size limit = 50000 k";
    }
    else {
    
       code............
    
  • -1

    有关不同的可用方法,请参阅PHP change the maximum upload file size .

    您可以使用多个上传页面(取决于您要设置的上传器限制),使用不同的.htaccess配置存储在不同的目录中,这样您就可以按上传限制对用户进行分组 .

  • 2

    将此添加到您的PHP

    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 40M
    
    ; Must be greater than or equal to upload_max_filesize
    post_max_size = 40M
    

相关问题