Upload script
Posted: Sat Jan 24, 2004 6:37 pm
Can anyone tell me whats wrong with my upload script ? When I'm choosing a file to upload it don't work...
Thanks in advance
Code: Select all
function upload()
{
//DATABASE INFO\\
require("../settings.php");
//DATABASE INFO\\
echo "<form name="form1" enctype="multipart/form-data" method="post" action="".$PHP_SELF."">";
echo "<table class="newsborder" border="0" cellspacing="5" cellpadding="0">";
echo "<tr>";
echo "<td><input type="file" name="file"></td>";
echo "<td><input type="hidden" name="MAX_FILE_SIZE" value="100000"><input name="submit" type="submit" value="Upload"></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
if (isset ($_POST["submit"]))
{
$container = array();
if($_POST["file"] == "")
{
array_push($container,"You must choose a file to upload.");
}
if (!count($container))
{
copy($file);
unlink($file);
$result = mysql_query ("INSERT INTO gallery (gallery_file) VALUES ('" . $_POST["file"] . "')", $connection);
if(!mysql_query($result))
array_push($container,"Something was not added. Error: " . mysql_error());
else
array_push($container,"File uploaded succesfully.");
}
}
}