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
| <?php include "connect.php";
$target = "files/";
$max_size = 100000; // Taille max en octets du fichier
$width_max = 100; // Largeur max de l'image en pixels
$height_max = 100; // Hauteur max de l'image en pixels
$extensions_ok = array(".jpg",".gif",".bmp",".jpeg");
$foto = $_FILES['photo']['name'];
$taille = $_FILES['photo']['size'];
$tmp = $_FILES['photo']['tmp_name'];
$chemin = $target.$_FILES['photo']['name'];
$extension = substr(strrchr($foto, "."), 0); // Récupération de l'extension
if($_POST['posted'])
{ // On vérifie si le champ est rempli
if($_FILES['photo']['name'])
{ // On vérifie l'extension du fichier
if(in_array(strtolower($extension),$extensions_ok))
{
if(move_uploaded_file($tmp,$chemin))
{ alert("Image téléchargée avec succès ! ");
}
else
{ alert("Problème lors du téléchargement ! ");
}}
else
{ // Sinon on affiche une erreur pour l'extension
alert("Votre image ne comporte pas une extension valide !");
}}
else
{
// Sinon on affiche une erreur pour le champ vide
alert("Le champs du formulaire est vide !");
}
}
$req = " INSERT INTO cv (nom,prenom,date_naiss,cin,ecivil,nation,email,tel,photo,diplom,theme,type_p,institut,module,liste,cooperation,rapport)
VALUES ('$nom','$prenom','$jj-$mm-$aa','$cin','$ecivil','$nation','$email','$tel','$photo','$diplom','$theme','$type_p','$institut','$module','$liste','$cooperation','$rapport')";
mysql_query($req) or die ('Erreur SQL!'. $req '<br />'. mysql_error());
mysql_close();
?> |
Partager