tags:

views:

55

answers:

1

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. below is 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 moments:

//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? thanking you in advance!

+2  A: 

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

Don Dickinson
this is what i'm getting display_errors = 1 register_globals = post_max_size = 32M post_max_size+1 = 33 post_max_size in bytes = 33554432
jeansymolanza