1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| }else {
// insert
if(isset($_FILES['html']) && $_FILES['html']!='')
{
$filename = $_FILES['html']['name'];
$userfile_type= $_FILES['html']['type'];
$upfile = 'pictures/'.$filename;
$allowed_types = array('application/pdf', 'application/msdoc');
}
elseif (!in_array($userfile, $allowed_types)) {
print 'Le fichier n\'a pas une extension valide';
exit;
}else{
move_uploaded_file($_FILES['html']['tmp_name'],
$upfile);
}
$sql = "insert into cours
(page, headline,story_text , created, modified, picture, userid)
values
('$page','$headline', '$story_text', $time, $time, '$filename', '"
.$_SESSION['userid']."')";
}
if(!isset($_FILES['html']))
{
$sql = "insert into cours
(page, headline,story_text , created, modified, picture, userid)
values
('$page','$headline', '$story_text', $time, $time, 'NULL', '"
.$_SESSION['userid']."')";
}
$result = mysql_query($sql, $conn);
if (!$result) {
print "Erreur d'exécution <pre>$sql</pre>";
print mysql_error();
exit;
}
echo $_FILES['html']; |
Partager