Jump to content

Can't get files over 1mb to upload. Please help.


kagronick

Recommended Posts

I've been struggling all day trying to get this to work.  PHP and Apache are installed and running.  I've been trying to get some very simple code to work.  Heres the html:

 

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

 

Heres the php:

<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

In php.ini upload_max_filesize is set to 32M

 

I tried adding LimitRequestBody 0 in httpd.conf.  Apache wouldn't start up.

 

So I think its something in Apache

 

Your code has zero error checking in it to get it to tell you why it is failing. At a minimum put the following diagnostic code in to see what the ['error'] element is telling you -

 

echo "<pre>";
print_r($_FILES);
echo "</pre>";

 

And also read this - http://us3.php.net/manual/en/features.file-upload.errors.php

 

And the following in your form will limit the size to 100,000 -

<input type="hidden" name="MAX_FILE_SIZE" value="100000" />

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.