Upload Script, NO size restriction!

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
User avatar
JustinMs66
Forum Contributor
Posts: 127
Joined: Sun Sep 03, 2006 4:18 pm

Upload Script, NO size restriction!

Post by JustinMs66 »

i have a working php upload script, but it only allows about up to 7MB and then it just goes to the error.
i want it to NOT have ANY size restriction. but i havn't restricted any sizes!!!!
can anyone help me with this!?

Code: Select all

<?php
//restricting file types i don't want to be uploaded:
$bad_types = array('application/octet-stream','application/x-php');
//if it's a bad file type, then display error:
if( in_array( $_FILES['uploadedfile']['type'], $bad_types ) )
{
    echo "That File type is not supported.";
}
else
{
//otherwise continue on the upload:
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
{
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "your file HAS been uploaded!";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
}
}
?>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you need to look in your php.ini file and change two settings:

max_post_size

and max_file_upload (or something like that)...just do a search for max and you'll find them both.
User avatar
JustinMs66
Forum Contributor
Posts: 127
Joined: Sun Sep 03, 2006 4:18 pm

Post by JustinMs66 »

php.ini?
i don't have that file.
or is it somewhere on the server?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

it's on the server.
User avatar
JustinMs66
Forum Contributor
Posts: 127
Joined: Sun Sep 03, 2006 4:18 pm

Post by JustinMs66 »

where!??
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

are you on a shared host? If so, you don't have access to it... you have to talk to your hosting company and there's no way any shared host on this planet is going to allow you to upload any size file you like... they may bump it up if you're lucky.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

in windows it's usually in the %systemroot% folder ie (C:\windows)

in *nix it varies depending on how you have your server configured.

on our server it's located here:

/usr/local/lib/php.ini
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Post by waradmin »

Isnt there code to override the max-upload php.ini limit?

If not, use a Javascript applet that does it over FTP.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

waradmin wrote:Isnt there code to override the max-upload php.ini limit?

If not, use a Javascript applet that does it over FTP.
don't you mean java applet?
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

@waradmin
You can't set max_post_size or max_upload_size with ini_set because the upload starts and completes before the first line of the script to be executed.
Post Reply