954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php mysql doesnt allow to upload more than 1mb file

Please help me on this file upload.

<form id="form_2" action="files_upload.php" method="post" enctype="multipart/form-data">
        	
     <input type="hidden" name="MAX_FILE_SIZE" value="50000000">
     File:<input type="file"  name="file" class="input" maxlength="350"" />
     <input type="submit" name="submit" value="Upload File">
</form>
<?php
if(isset($_POST['submit']) && $_FILES['file']['size'] > 0)
{
$fileName = $_FILES['file']['name'];
$tmpName  = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileType = $_FILES['file']['type'];

$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);


if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}

mysql_connect('localhost', 'username', '*********') or die(mysql_error());
mysql_select_db('db') or die(mysql_error());


$query = "INSERT INTO `db`.`upload` (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

mysql_query($query) or die('Error, query failed');
//include 'library/closedb.php';

echo "File $fileName uploaded";
echo "<a href=\"index.php\">[Back]</a>";
}
?>
manzoor.ilahi77
Newbie Poster
14 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

php.ini is to be modified for limit of file size. html parameter will not help

urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 

open php.ini (must be at your MAIN PHP directory)
edit those two lines:

post_max_size = 2M
upload_max_filesize = 2M


Enter what ever you want for value.

P.S. Don't forget, after change those settings you need to restart your webserver(apache or what ever you use)!

sv3tli0
Junior Poster in Training
78 posts since Aug 2011
Reputation Points: 10
Solved Threads: 18
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: