Jump to content

Allowing larger upload file


ponies3387

Recommended Posts

Im having issues allowing a larger upload file size. I would like to allow 5mbs, the script below allows 2mb right? So ive tried changing the number to 3000000, 4000000, 5000000, but it wont allow the jpeg file im sending that is 2.22mb, it will allow a file that is 1.8mb, but even though I change the "if( $upload_Size >2000000)" to "if( $upload_Size >3000000)", and re-transfer it to my server it still doesnt work. Im not sure how to check what my server allows, I think this might be the right information:

 

Bandwidth Allotment:

250,000 MB

Diskspace Allotment:

5,000 MB

 

but im not sure. So im thinking maybe theres another way I can allow this change? or maybe i need to do more to the script than just change the number???

 

 

 // CHANGE THIS TO A HIGHER OR LOWER VALUE - REMEMBER HOSTING LIMITS
if( $upload_Size >2000000)
//--------
{
unlink($upload_Temp);
die("<p align='center'><b><font face='Arial Black' size='2' color='#FF0000'>ERROR<br>YOUR FILE WAS NOT UPLOADED<br>PLEASE CHECK THE FILE SIZE AND FORMAT</font></b></p>");
}
if( $upload_Mime_Type != "image/cgm" AND $upload_Mime_Type != "image/g3fax" AND $upload_Mime_Type != "image/gif" AND $upload_Mime_Type != "image/ief" AND $upload_Mime_Type != "image/pjpeg" AND $upload_Mime_Type != "image/jpeg" AND $upload_Mime_Type != "image/naplps" AND $upload_Mime_Type != "image/png" AND $upload_Mime_Type != "image/prs.btif" AND $upload_Mime_Type != "image/prs.pti" AND $upload_Mime_Type != "image/tiff" AND $upload_Mime_Type != "image/vnd.cns.inf2" AND $upload_Mime_Type != "image/vnd.dwg" AND $upload_Mime_Type != "image/vnd.dxf" AND $upload_Mime_Type != "image/vnd.fastbidsheet" AND $upload_Mime_Type != "image/vnd.fpx" AND $upload_Mime_Type != "image/vnd.fst" AND $upload_Mime_Type != "image/vnd.fujixerox.edmics-mmr" AND $upload_Mime_Type != "image/vnd.fujixerox.edmics-rlc" AND $upload_Mime_Type != "image/vnd.mix" AND $upload_Mime_Type != "image/vnd.net-fpx" AND $upload_Mime_Type != "image/vnd.svf" AND $upload_Mime_Type != "image/vnd.wap.wbmp" AND $upload_Mime_Type != "image/vnd.xiff" )
{
unlink($upload_Temp);
die("<p align='center'><b><font face='Arial Black' size='2' color='#FF0000'>ERROR<br>YOUR FILE WAS NOT UPLOADED<br>PLEASE CHECK THE FILE SIZE AND FORMAT</font></b></p>");
}
$uploadFile = "uploads/".$upload_Name ;
if (!is_dir(dirname($uploadFile)))
  {
    @RecursiveMkdir(dirname($uploadFile)); 
  }
else
  {
  @chmod(dirname($uploadFile), 0777);
  }
@move_uploaded_file( $upload_Temp , $uploadFile); 
chmod($uploadFile, 0644);

 

oh and, thats not the full code, just a snipet that had to do with the file size, I didnt see any other part of the script related to uploading.

Link to comment
https://forums.phpfreaks.com/topic/89985-allowing-larger-upload-file/
Share on other sites

1KB = 1024

1MB = 1024 / 1024

 

Therefore, do something like

 

<?php

function fileSize() {
  $filesize = $_FILES['file']['size'];
  $filesize = $filesize / (1024 / 1024);

  if($filesize >= 5) {
    echo 'Your file is larger than 5MB';
  } else {
    echo 'Your filesize is below 5MB';
  }
}
?>

1KB = 1024

1MB = 1024 / 1024

 

Therefore, do something like

 

<?php

function fileSize() {
  $filesize = $_FILES['file']['size'];
  $filesize = $filesize / (1024 / 1024);
  $filesize = floor($filesize);

  if($filesize >= 5) {
    echo 'Your file is larger than 5MB';
  } else {
    echo 'Your filesize is below 5MB';
  }
}
?>

 

Try that even

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.