Problem Uploading Larger Files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hadenp
Forum Newbie
Posts: 4
Joined: Tue Jul 20, 2010 8:13 pm

Problem Uploading Larger Files

Post by hadenp »

When I upload files > 1 MB, I get an "Internal Server Error" and in the errors log see "Premature end of script headers:"
No problem uploading smaller files. The site is hosted on GoDaddy and they have a default 'upload_max_filesize = 8M'. Before I found this out, I set this value (along with others) in my php5.ini file, located in the same directory where the upload script resides. I've also set permissions on the directory that I upload to to 777. I tried my script on a different server (also Linux) and am able to upload larger files successfully.

Any thoughts on what's going on are greatly appreciated!

Code: Select all

<?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { ?>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'] ?>"
      enctype="multipart/form-data">
<input type="file" name="document"/>
<input type="submit" value="Send File"/>
</form>
<?php } else { 
    if (isset($_FILES['document']) &&
    ($_FILES['document']['error'] == UPLOAD_ERR_OK)) {
        $newPath = 'updocs/' . basename($_FILES['document']['name']);
        if (move_uploaded_file($_FILES['document']['tmp_name'], $newPath)) {
            print "File saved in $newPath";
        } else {
            print "Couldn't move file to $newPath";
        }
    } else {
        print "No valid file uploaded.";
    }
}
?>

Code: Select all

magic_quotes_gpc = Off
log_errors = on
display_errors = off
memory_limit = 64M

post_max_size = 10M
upload_max_filesize = 8M
max_input_time = 360
max_execution_time = 360
upload_tmp_dir = amd_temp
Post Reply