Jump to content


Photo

uploading files and the php.ini


  • Please log in to reply
1 reply to this topic

#1 juanc

juanc
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 10 May 2006 - 08:32 PM

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


<?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

}

?>




#2 Yojance

Yojance
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 10 May 2006 - 08:49 PM

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

upload_max_filesize (integer)M
Scope: PHP_INI_SYSTEM, Default value: 2M
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 :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users