Uploading and downloading files
Posted by: janculis (80.233.247.---)
Date: July 28, 2006 04:20PM

Hi!
I have some problem.
I want create a nice home page, where people can upload some file and it download.
So I wanted to insert these files in DB.
But my code does not working. sad smiley
I cannot insert into database file.

So...
My code is here:
<?php
if ($action == "upload"winking smiley {
include "open_db.inc";

$txtDescription= $_POST['txtDescription'];
$binFile= $_POST['binFile'];

if (isset($binFile) && $binFile != ""winking smiley {
$data = addslashes(fread(fopen($binFile, "r"winking smiley, filesize($binFile)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO tbl_Files (
description,
bin_data,
filename,
filesize,
filetype)
VALUES (
'$strDescription',
'$data',
'$binFile_name',
'$binFile_size',
'$binFile_type')";
$result = mysql_query($sql, $db);
mysql_free_result($result);
if(!$result) {die('Neievietoja datus:' .mysql_error());}
echo "Jauns ieraksts pievienots.";
echo "Thank you. The new file was successfully added to our database.<br><br>";
echo "<a href='main.php'>Continue</a>";
}
mysql_close();

} else {
?>
<HTML>
<BODY>
<FORM METHOD="post" ACTION="<?php echo $PHP_SELF;?>" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="1000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1">
<TR>
<TD>Description: </TD>
<TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binFile"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="upload"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<?php
}
?>

In the file open_db.inc everything is OK. When I manualy insert in DB some information, it apears, so my problem starts there...
I use WAMP5 Version 1.6.4 with standart options.
Can anybody help me?

Options: ReplyQuote


Sorry, only registered users may post in this forum.