0

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>";
}
?>
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by sv3tli0
0

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)!

Edited by sv3tli0: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.