/    Sign up×
Community /Pin to ProfileBookmark

Problem with PHP Upload script

So I am having problems when uploading larger files via an upload script. I am finding that once a file is over 20mb or so the script pretty much fails and the $_FILES[‘file’] array is empty. However, if I upload a smaller file it works fine.

I initially thought it was an issue with my upload_max_filesize in my php.ini, however when I set it to 100M the script is still failing.

Here is a link to a php info dump:
[url]http://theelysium.net/info.php[/url]

And here is my upload class:

[code=php]
class ImageUploader{
public function ImageUploader(){
global $root, $errors, $errorText, $media_url;

$errors = false;

if(!eregi(‘image/’, $_FILES[‘file’][‘type’]) && $_FILES[“file”][“type”] != “audio/mp3” && $_FILES[“file”][“type”] != “audio/mpeg”) {
$errorText .= “You must upload an image file”;
$errors = true;
};

$image_cap = 900;
$sound_cap = 70000;

if(eregi(‘image/’, $_FILES[‘file’][‘type’]) && $_FILES[‘file’][‘size’]/1024 > $image_cap){
$errorText .= “The image you are uploading must be 900Kb or smaller”;
$errors = true;
};

if( $_FILES[“file”][“type”] != “audio/mp3” || $_FILES[“file”][“type”] != “audio/mpeg”){
if($_FILES[‘file’][‘size’]/1024 > $sound_cap){
$errorText .= “The sound file you are uploading must be 70Mb or smaller”;
$errors = true;
}
}

if($_FILES[‘file’][‘name’] == “”){
$errorText .= “Please specify a file to upload.”;
$errors = true;
}

if($errors == false){

$path = $root.”clientImages/” . $_GET[‘client’] . “/”;

$this->makeDirectory($path);
$path .= $_GET[‘app’].”/”;
$this->makeDirectory($path);

$fn = explode(“.”,$_FILES[‘file’][‘name’]);

$name = $_GET[‘client’].”-“.$_GET[‘app’].”-“.$_GET[‘post’].”-“.floor(rand(0,99999)).”-“.$this->strip($fn[0]).”.”.$fn[sizeof($fn)-1];

$name = strtolower(str_replace(” “,””,$name));
$name = str_replace(“(“,””,$name);
$name = str_replace(“)”,””,$name);

$filePath = $path.$name;

$location = “http://”.$media_url.”/clientImages/” . $_GET[‘client’] . “/” . $_GET[‘app’].”/” . $name;

move_uploaded_file($_FILES[‘file’][‘tmp_name’], $filePath);
}

}

private function makeDirectory( $dirPath ){
if( !is_dir( $dirPath ) ){
if ( mkdir( $dirPath ) ){
return true;
}else{
return false;
}
}
}

private function strip($string){
return preg_replace(“/[^a-zA-Z0-9s]/”, “”, $string);
}

}[/code]

Thanks so much for any help yo can offer!

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@DariaOct 07.2011 — I still see 20 under max_file_uploads...
Copy linkTweet thisAlerts:
@mortalgodauthorOct 07.2011 — I was under the impression that upload_max_filesize was the size of files and max_file_uploads had something to do with how many files can be sent at once?
Copy linkTweet thisAlerts:
@DariaOct 07.2011 — "Oops, I did it again". You are correct. Sorry - "5-too-many-coffees" for me.

So you only want to have the limit on the SOUND files, right?
Copy linkTweet thisAlerts:
@criterion9Oct 07.2011 — Also check that max post size has been increased as well. It needs to be a high enough number to include all other POST data in addition to the file being transferred.
Copy linkTweet thisAlerts:
@mortalgodauthorOct 07.2011 — That looks like it may be it! Thanks, seems like my host is making me jump through hoops to change that variable. If it doesnt work out I will let you know.

THANKS!
Copy linkTweet thisAlerts:
@DariaOct 07.2011 — Yep, it happens on the shared server. If they don't budge, you may need to go dedicated for this to have full control.
Copy linkTweet thisAlerts:
@mortalgodauthorOct 07.2011 — Ya, sadly budget for this project does not have space for the upgrade from $6/month to $80-100/month for dedicated. We will see how they respond, crossing my fingers.
Copy linkTweet thisAlerts:
@mortalgodauthorOct 07.2011 — woot got access!! Thanks for all your help! Bug = Solved ?
Copy linkTweet thisAlerts:
@deemi_pkOct 12.2011 — Bother eregi() Function is [U]Depricated[/U] so i Think this reasin that your code not work !
×

Success!

Help @mortalgod spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...