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

 

Link to comment
Share on other sites

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" />

 

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.