1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| $uploaddir = "../files/$menu1/";
$filename = trim($_FILES['upfile']['name']);
$filename = substr($filename, -20);
$filename = ereg_replace(" ", "", $filename);
if((ereg(".jpg", $filename)) || (ereg(".mp3", $filename)) || (ereg(".txt", $filename)) || (ereg(".pdf", $filename)) || (ereg(".zip", $filename))) {
$uploadfile = $uploaddir . $filename;
if (move_uploaded_file($_FILES['upfile']['tmp_name'],
$uploadfile)) {
chmod($uploadfile, 0644);
print("File upload was successful");
echo $filename;
$db_con = mysql_connect($sql_serveur,$sql_user,$sql_passwd);
$req=mysql_db_query($sql_db,"select module_id from libertux_modules where module=\"$menu1\"",$db_con);
$mod=mysql_result($req,0,"module_id");
$requete=mysql_db_query($sql_db,"insert into libertux_cours (modul_id,titre,fichier,Date,info) values (\"$mod\",\"$titre\",\"$filename\",\"$date\",\"$info\")",$db_con);
} else {
print("File upload failed");
}
} else {
print("Only images are allowed, upload failed");
} |