drgwsx8405 2010-03-01 22:37
浏览 102
已采纳

文件上传限制为1MB?

I can't understand why my server isn't accepting files larger than 1MB. I am using cpanel and my host has told me that I can't edit my php.ini file directly.

My upload code:

<?php
if (array_key_exists('uploadfile', $_POST)) {
    $fileName = $_FILES['userfile']['name'];
    $tmpName  = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];

    $fp      = fopen($tmpName, 'r');
    $content = fread($fp, filesize($tmpName));
    $content = addslashes($content);
    fclose($fp);

    if (!get_magic_quotes_gpc()) {
        $fileName = addslashes($fileName);
    }

    mysql_query("INSERT INTO tbl_vehiclefiles (`veh_id`,`name`,`type`,`size`,`content`)
VALUES ('$veh_id', '$fileName', '$fileType', '$fileSize','$content')");

    echo '<b>File Upload</b><p>Thank you. The file has been successfully uploaded.

<p><img src="resources/spacer.gif" alt="" width="300px" height="5px" /><p><o>

<i><u>Name:</u>&nbsp;' . $fileName . '<p><i><u>Size:</u>&nbsp;' . $fileSize . 'k' . '<p><u>Type:</u>&nbsp;' . $fileType . '</i><p><p><img src="resources/spacer.gif" alt="" width="300px" height="5px" />';

    $file_id = mysql_insert_id();

    echo "</i><p><a href='managevehicle.php?id=$veh_id' class='form'>Manage details</a><p>
         <a href='viewfile2.php?id=$file_id' class='form'>View details</a><p>";
    exit;
}
?>      

<b>File Upload</b></p>
   <p>
     <input type="hidden" name="MAX_FILE_SIZE" value="200000000">
     <span id="sprytextfield1">
     <input name="userfile" type="file" id="userfile">
    </span><BR />
    <input type="hidden" name="uploadfile" value="1"/> 
    <input name="upload" type="submit" id="upload" value=" Upload ">
   </p>

I was told that I could create my own php.ini file and save it on cpanel file manager to override some of the php.ini values. This is what I have on it at the moment:

//Common local changes:

upload_max_filesize = 20M; // (default 8 - Max, 32)
post_max_size = 20M; // (Average, 20 - Max, 32)
register_globals = Off; // (off by default - you can turn On) 
allow_url_fopen = On; // (off by default - you can turn to On)
memory_limit = 24M; // (default of 8M, Max 32)

but it has no effect! Any suggestions?

  • 写回答

2条回答 默认 最新

  • dqoys62082 2010-03-01 22:44
    关注

    i would start by reading the max upload size with init_get - do this to be sure that your value is being accepted: http://php.net/manual/en/function.ini-get.php

    if you want to change the value with your script, you can use init_set: http://php.net/manual/en/function.ini-set.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表