Uploader size

Started on the old forum in September 2009 · view the original in the archive · old links redirect here

15 replies · 736 views · started 17 years ago · 1 min read

6 participants
riderz Lead · 975 posts #1

i have a small error everytime i try to upload a file bigger than 1mb it say so no input space

<?
    session_name("PHPSESSID");
session_start();
function get_files($dirstr)
  {
   $scanfiles = array();
   $fh = opendir($dirstr);
   while (false !== ($filename = readdir($fh)))
   {
if (is_file("$dirstr/$filename")) {
     array_push($scanfiles, $filename); }
   }
   closedir($fh);
   sort($scanfiles);
   return $scanfiles;
}

$count = count($_FILES['userfile']['name']);
if ($count > 0) {

$i=0;
$f=0;
while ($i < $count) {

$kbsize = (round($_FILES['userfile']['size'][$i]/5000));
$date = date("j M Y g:ia", time()+($timeoffset*3600));
$userip = $_SERVER['REMOTE_ADDR'];

if ($limitsize == 1) {
if ($_FILES['userfile']['size'][$i] > (1024*$maxsize) ) {
$toobig[$i] = "{$_FILES['userfile']['name'][$i]} is too large! the maximum file size is $maxsize kb.";
} }

if ($acceptfilter == 1) {
if (!in_array($_FILES['userfile']['type'][$i], $acceptabletypes)) {
$rejectstring = "{$_FILES['userfile']['name'][$i]} is not of the type ";
foreach ($acceptabletypes as $acceptabletype) {
$rejectstring .= "$acceptabletype or "; }
$rejectstring = substr($rejectstring, 0, -4);
$notacceptable[$i] = "$rejectstring.";
} }

if ($overwriting !== 1) {
if(file_exists("pkfiles/{$_FILES['userfile']['name'][$i]}")) {
$alreadyexists[$i] = "a file of the name {$_FILES['userfile']['name'][$i]} already exists! overwriting is not permitted.";
} }

if (!isset($toobig[$i]) && !isset($notacceptable[$i]) && !isset($alreadyexists[$i])) {
$file="{$_FILES['userfile']['name'][$i]}";
$videsc = $_POST["videsc"];
if(spacesin($file))
{
        echo "No input space!.<br/>";
 }else{
if (!eregi("\.(mid|gif|bmp|mid|midi|3gp|mp3|mp4|wav|mpn|nth|mpc|jar|jad|jpeg|jpg|sis|mmf|amr|thm|png|wbmp|rar|zip)$",$file))
{
 echo "Unsupported file extension!<br/>";
 }else{

copy($_FILES['userfile']['tmp_name'][$i], "pkfiles/{$_FILES['userfile']['name'][$i]}");
echo "{$_FILES['userfile']['name'][$i]}<br>";
$ext = getext($file);
        $mime = getextfile($ext);
$file = "{$_FILES['userfile']['name'][$i]}";
$filesize = filesize("./pkfiles/".$file);
$filesize = $filesize / 50000;
$fsize = 0;
$fsizetxt = "";
  if ($filesize < 1)
  {
     $fsize = round($filesize*50000);
     $fsizetxt = "".$fsize." KB";
    $check1 = "KB";
  }else{
     $fsize = round($filesize,2);
     $fsizetxt = "".$fsize." MB";
$check1 = "MB";
  }
 $info = "<br/>Name<br/>".$file." Type<br/>".$mime." Size<br/>".$fsizetxt."";
$res = mysql_query("INSERT INTO ibwf_vault SET uid='".$uid."', title='".$file."', pudt='".time()."', did='".$did."', info='".$info."', filesize='".$fsizetxt."', mime='".$mime."', itemurl='".$file."'");
      if($res)
      {
        echo "File successfully uploaded!<br/>";
      }else{
        echo "Invalid or already in our database!<br/>";
      }
}

}
$f++;
$content .= "$date $userip uploads pkfiles/{$_FILES['userfile']['name'][$i]} ($kbsize kb)\n";
}

elseif ($_FILES['userfile']['size'][$i] !== 0) { 
echo "$toobig[$i] $notacceptable[$i] $alreadyexists[$i]<br>"; 
$content .= "$date $userip fails to upload $uploaddir/{$_FILES['userfile']['name'][$i]} ($kbsize kb) - $toobig[$i] $notacceptable[$i] $alreadyexists[$i]\n";
}

$i++;   
}

if ($makelog == 1) {
$handle = fopen("$logfile", "a");
fwrite ($handle, $content);
fclose ($handle); }

}

?>

<form action="<?= $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; ?>" method="post" enctype="multipart/form-data">
  Add files and Get 5 Plusses for Every Downloads :)
<br>

<?
for($d=0; $d < $fields; $d++) {

echo "<input name=\"userfile[]\" type=\"file\" size=\"30\"><br>"; 

}
?>
  Category:<br/><select name="did">
  <option value="1">Symbian Software</option>
 <option value="2">Java Software</option>
 <option value="3">Anti Virus</option>
<option value="4">s40v2/s40v3 Themes</option>";
  <option value="5">s60/s60v3/Nseries Themes </option>
 <option value="6">Sony Ericsson Themes </option>
  <option value="7">s30/40/s40v2 Games </option>";
  <option value="8">s60/s60v3 Games </option>";
  <option value="9">Eseries/Nseries/Ngage Games </option>
 <option value="10">Sony Ericsson Games</option>
 <option value="11">Full MP3</option>
  <option value="12">3GP Videos</option>
 <option value="13">Scandal</option>
<option value="14">Gameboy Games</option>
 <option value="15">Naruto Themes/Poly/MP3</option>
 <option value="16">MP3/MIDI/WAV/POLY/AMR/RAR</option>
     <option value="17">Opera Software</option>
 <option value="18">Jpeg Gif Png</option>
  </select><br/>

<input type="submit" value="Upload now">
</form>

<?

echo "<ul>";

if ($limitsize == 1) {
echo "<li><b>The Maximum File size is 5MB.</b></li>"; }

echo "</ul>";
if ($ver==wml)
{
echo "<a href=\"index.php?action=vault\">Downloads</a><br/>";
echo "<a href=\"index.php?action=main\">Main menu</a><br/>";
}else{ 
echo "<a href=\"index.php?action=vault\">Downloads</a><br/>";
echo "<a href=\"index.php?action=main\">Main menu</a>";
}
unset($count, $acceptabletypes, $handle, $content, $date, $kbsize);

?>

Jacques jacques@gw-designs.co.za http://coding.biz.tm Come join and lets make it a place to learn all the noobies how to code


NEVER FORGET TO CLICK THE TANX BUTTON IF U LIKE WHAT IM SHARING OR HELPING WITH

capofret Developer · 225 posts #4

loony wrote: here try these ur htaccess file

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200

is it host/server dependent? i mean, can any host handle 20M or bigger filesize?

just wondering...

LDSWAPWORLD site closed. im busy with other things in life like facebook , send me PM so i can add you 🙂 www.pinoySG.com

don't ask for help if you're not even helping yourself! i am tired of seeing the line "best site", i want to see something NEW and UNIQUE. maybe if i find one, ill go back to my wap life again.

External image (may be gone)

riderz Lead · 975 posts #5

mine can upload any limit of size only if there are enought disk space left i use to upload stuff that are 30mb lol


Jacques jacques@gw-designs.co.za http://coding.biz.tm Come join and lets make it a place to learn all the noobies how to code


NEVER FORGET TO CLICK THE TANX BUTTON IF U LIKE WHAT IM SHARING OR HELPING WITH

xws.developer Junior · 10 posts #6

Where is the function defination for spacesin() ??

Try not to become a man of success but rather to become a man of value. Co-Developer of http://chatmasti.mobi

spiderwebs Developer · 193 posts #7

rider use the code which loony has told to in ur .htacess all will work fine and capofret its not dependent on host

E107 Security Team Leader Proudly Support AccountLab Plus Billing Software

Want your Apps to be Developed ??? mail us your requirement at info@csarlab.com

capofret Developer · 225 posts #8

riderz wrote: mine can upload any limit of size only if there are enought disk space left i use to upload stuff that are 30mb lol

so u can upload any file size with that uploader script? how about downloading that file? im not talking about thru ftp because we all know we can upload any file size thru that.

i want to learn thats why im asking to clarify 🙂

LDSWAPWORLD site closed. im busy with other things in life like facebook , send me PM so i can add you 🙂 www.pinoySG.com

don't ask for help if you're not even helping yourself! i am tired of seeing the line "best site", i want to see something NEW and UNIQUE. maybe if i find one, ill go back to my wap life again.

External image (may be gone)

riderz Lead · 975 posts #9

capofret thats where i have a prob i dnt get that file to upload more than 1mb ive uploaded the htaccess file that they gave but still it dnt upload bigger files


Jacques jacques@gw-designs.co.za http://coding.biz.tm Come join and lets make it a place to learn all the noobies how to code


NEVER FORGET TO CLICK THE TANX BUTTON IF U LIKE WHAT IM SHARING OR HELPING WITH

xws.developer Junior · 10 posts #10

Looks like the size of file is being checked in function spacesin() and the defination of the function is no where in the code you have given. Find where this function has been defined and edit it. Hope this will work for you

Try not to become a man of success but rather to become a man of value. Co-Developer of http://chatmasti.mobi

riderz Lead · 975 posts #11
//////////////////////////////////////////////////MISC FUNCTIONS
function spacesin($word)
{
  $pos = strpos($word," ");
  if($pos === false)
  {
    return false;
  }else
  {
    return true;
  }
}

this one is in core


Jacques jacques@gw-designs.co.za http://coding.biz.tm Come join and lets make it a place to learn all the noobies how to code


NEVER FORGET TO CLICK THE TANX BUTTON IF U LIKE WHAT IM SHARING OR HELPING WITH

xws.developer Junior · 10 posts #13

This script wont allow you to upload files which have a space in there name. Just remove the spaces and your problem will be solved. Hope this will help

Try not to become a man of success but rather to become a man of value. Co-Developer of http://chatmasti.mobi

riderz Lead · 975 posts #14

yea gotten the prob it had spaces in when ive uploaded it


Jacques jacques@gw-designs.co.za http://coding.biz.tm Come join and lets make it a place to learn all the noobies how to code


NEVER FORGET TO CLICK THE TANX BUTTON IF U LIKE WHAT IM SHARING OR HELPING WITH

down16 Junior · 39 posts #15

hmmm, i can not find the htd acesss to put higher for iles

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close