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 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| if (isset($_POST['submit']))
{
/*messageAlert('danger','Ok',' : C\'est en ordre');*/
/*affiche le message à droite suite à une sélection de fichier*/
$pseudo = $_SESSION['pseudo'];
$req = $bdd -> query("SELECT * FROM personne ");
$donnees = $req -> fetch();
$pv=$donnees['per_pseudo'];
$req = $bdd -> query("SELECT * FROM personne ");
$donnees = $req -> fetch();
$idann=$id;
$pc=$pseudo;
$poste=$pseudo;
$file = $_FILES['file'];
$fileName = $_FILES['file']['name']; // OU : $file['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileError = $_FILES['file']['error'];
$fileType = $_FILES['file']['type'];
$fileExt = explode(".",$fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('jpg','jpeg','png','pdf','PNG','JPG','JPEG','PDF');
/*messageAlert('success','Réussi',', on est là, '.$fileName.', '.$fileActualExt.', '.$fileError.', '.$fileSize);*/
if (in_array($fileActualExt,$allowed)) {
if ($fileError === 0) {
if ($fileSize < 10000000) {
$fileNameNew = uniqid('',true).".".$fileActualExt;
$fileDestination = "images/ads/imagesconversation/".$fileNameNew;
move_uploaded_file($fileTmpName,$fileDestination);
$bdd = bdd();
$roc=$bdd->query("INSERT INTO messages VALUES ('','$idann','$pc','$pv','','','','','','','$fileNameNew','','','','','','','','','','','','','')");
//$bdd->query("DELETE FROM messages WHERE mess_c_date='' and mess_c_datef='' and mess_v_datef='' and mess_v_date=''");
//$roc->execute()
print_r($roc);
messageAlert("success", "Succès : ", "BRAVO, votre fichier est envoyé !!");
}
else
{
messageAlert("danger", "Erreur :","Votre fichier est trop lourd !");
}
}
else
{
messageAlert("danger", "Erreur :", "Il y a eu une erreur lors du téléchargement !");
}
}
}
?> |
Partager