<?php
/*
###############################################################################
# upload.php #
###############################################################################
# FDat (File Database) Beta Version #
# Open-Source Project by Jeffrey Gelens (hide@address.com) #
# =========================================================================== #
# Copyright (c) 2001 Jeffrey Gelens - All Rights Reserved #
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
###############################################################################
*/
require ('../settings.php');
require ('functions.php');
head();
head2();
if (isset($file)) {
mysql_connect ($database['host'], $database['username'], $database['password']) or die ("Can't connect to database server");
mysql_select_db ($database['name']) or die ("Database doesn't exist, check settings.php");
$filename = $HTTP_POST_FILES['file']['name'];
$filetype = $HTTP_POST_FILES['file']['type'];
if (empty($filetype)) {
$filetype = "unknown";
}
$fp = fopen($file, "rb");
if (!$fp) {
echo "Can't open file!";
}
$data = fread($fp, filesize($file));
$fp = fclose($fp);
if (file_exists("$fdathostdir/$filename") != 1) {
$fp = fopen ("$fdathostdir/$filename", "wb");
$fp = fwrite ($fp, $data);
if (!$fp) {
echo "Failed to upload file!";
}
else {
echo "File uploaded!";
}
$fp = fclose($fp);
$user = get_User($koekje);
$sql = "INSERT INTO files VALUES ('', '$filename', '$filetype', '$description', '$which_subject', '$school', '$rank', '$user')";
$result = mysql_query($sql);
}
else {
echo "File already exist, rename it!";
}
}
foot();
?>