Jump to content

uploading files and the php.ini


juanc

Recommended Posts

Here’s a weird one for you all out there……….

I wrote a script for a client that want’s to be able to upload pdf files that can sometimes be up to 12 meg ………..but typically 3 to 6.

Anything up to 5 meg works fine but anything over that and the upload fails…………here’s the weird part………..my hosting service has increased both the post_max_size and upload_max_filesize to 12 m in each case. You can see my phpinfo() here: [a href=\"http://www.digital-services.co.uk/check.php\" target=\"_blank\"]www.digital-services.co.uk/check.php[/a]

However when I do

echo $_FILES[‘uploadedFile’][‘error’]

it gives “1” the error code for when the file exceeds the upload_max_filesize………..plus the error log that gets generated says so too……..

here’s the lines from it…..

[25-Apr-2006 16:24:30] PHP Warning: POST Content-Length of 12243998 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

[10-May-2006 08:54:33] PHP Warning: upload_max_filesize of 5242880 bytes exceeded - file [uploadedFile=Derrick May - Strings of Life (Original Mix).mp3] not saved in Unknown on line 0

My guess is that as it’s some form of shared platform so the ini file I’m seeing isn’t really in respect of my instance of php.

Before anyone says "contact your helpdesk" I already have but am still waiting to hear from them................I thought perhaps someone might know what the answer could be.

Here’s the script I wrote

[code]

<?php
set_time_limit(0);
if($_POST['submit'])
{
   echo "The file is now uploading";
    if(copy($_FILES['uploadedFile']['tmp_name'],  "pdfs/" . $_FILES['uploadedFile']['name']))
      {
        echo "<br /><br />The file has been uploaded successfully";
        
        unlink($_FILES['uploadedFile']['tmp_name']);
      }
    else
      {
        echo "The file was not uploaded<br /><br />";
        echo "The error is <b> " . $_FILES['uploadedFile']['error'] . "</b>";        
      }    
      
      echo "<br /><br /><a href=" . $_SERVER[PHP_SELF] . ">Upload another file</a>";      
        
}
else
{

?>

<form action="<?php echo $_SERVER[PHP_SELF] ?>" method="post" enctype="multipart/form-data">
File: <input type="file" name="uploadedFile" />
<input type="submit" name="submit" value="Submit" />
</form>


<?php

}

?>


[/code]
Link to comment
Share on other sites

I'm a total noob in PHP, a quick look at my php book I use to learn at the moment, it says this.

[b]upload_max_filesize [/b][i](integer)M[/i]
Scope: [i]PHP_INI_SYSTEM[/i], Default value: [i]2M[/i]
The upload_max_filesize directive determines the maximum size, in megabytes of an uploaded file. This directive should be smaller than post_max_size, becayse it applies only to information passed via the file input type, and not to all information passed via the POST instance. Like memoery_limit, note tha an M must follow the integer value.

Just wrote this entirely from the book, I hope it helps. It does sound related to your problem, but I'm the n00b here :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.