Jump to content

max_file_size downloading files using a form


thosecars82

Recommended Posts

hello guys

i've got this code to download files. And the thing is that i do not why i can download any file whether its size is above or below the value given for max_file_size. According to the code I eventually put which is described below, it should not download any file which has size above max_file_size = 0 bytes. Nevertheless, it still downloads files with size >0. So, any idea about, why this value for max_file_size is not being useful in stopping the download of files with size above 0?

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<?PHP

if ($_POST['send']) {

if ($_FILES['downfile'] != "none" AND $_FILES['downfile']['size'] != 0){

echo "Name: ".$_FILES['downfile']['name']."<BR>\n";

echo "Size: ".$_FILES['downfile']['size']." <BR>\n";

echo "Type: ".$_FILES['downfile']['type']." <BR>\n";

 

// for Windows

if (! copy ($_FILES['downfile']['name'], "C:\caca\\".$_FILES['downfile']['name'])) {

echo "<h2>File could not be copied</h2>\n";

}

else

  echo "great";

/* for Linux/Unix

if (! copy ($_POST['downfile'], "/tmp/".$_POST['file_name'])) {

echo "<h2>File could not be copied</h2>\n";

}

} */

}

elseif (($_FILES['downfile']['name'] != "none") AND ($_FILES['downfile']['name'] == 0)) {

echo "<h2>File size exceded exceded</h2>\n";

}

else {

echo "<h2>You haven't choose a new file to download</h2>\n";

}

echo "<HR>\n";

}

?>

<FORM ENCTYPE="multipart/form-data" ACTION="<?php echo $PHP_SELF ?>" METHOD="post">

<INPUT type="hidden" name="MAX_FILE_SIZE" value="0">

<p><b>File to download<b><br>

Example

<INPUT type="file" name="downfile" size="35"></p>

<p><INPUT type="submit" name="send" value="Accept"></p>

</FORM>

</body>

</html>

 

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.