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"" /><br />
<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 "<br>File $fileName uploaded<br>";
echo "<br><a href=\"index.php\">[Back]</a><br>";
}
?>