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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
<?php
//TRAITEMENT DE L'IMAGE
$nomOrigine = $_FILES['monfichier']['name'];
//pathinfo Retourne des informations sur un chemin système
/* pathinfo() retourne des informations sur le chemin path, sous forme de chaine ou de tableau associatif, ceci dépend du paramètre options. */
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = $elementsChemin['extension'];
$extensionsAutorisees = array("jpeg", "jpg", "gif");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
echo "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
// incluant l'heure a la seconde pres
$repertoireDestination = dirname(__FILE__)."/upload_img/";
//$nomDestination = "fichier_du_".date("YmdHis").".".$extensionFichier;
$espace = '_';
$identimag = $nom . $espace . $societe;
$nombre=1;
$count2=$count+$nombre;
//$count++;*/
$identimag .= $count2;
$nomDestination = "image_".$identimag.".".$extensionFichier;
if (move_uploaded_file($_FILES["monfichier"]["tmp_name"], $repertoireDestination.$nomDestination)) {
echo "Le fichier temporaire ".$_FILES["monfichier"]["tmp_name"]." a été déplacé vers ".$repertoireDestination.$nomDestination;
} else {
echo "Le fichier n'a pas été uploadé (trop gros ?) ou "."Le déplacement du fichier temporaire a échoué"." vérifiez l'existence du répertoire ".$repertoireDestination;
}
}
?>
<form style="font-family:verdana,geneva;" action="FormEnvoiImage1_bis.php" method="post" width="597" enctype="multipart/form-data">
<fieldset style="border: 1px solid #AFD3F3;background-color:#D0DEEA;">
<legend style="color:#447093;font-family:verdana,geneva;font-size:16px; font-weight:bold"></legend>
</fieldset>
<!---- formulaire -->
<fieldset style="border: 1px solid #AFD3F3;background-color:#E9F2FC;">
<legend style="color:#447093;font-family:verdana,geneva;font-size:18px; font-weight:bold">Formulaire d'envoi d'image <br/>
</legend>
<table width="867" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td colspan="2"><label for="message">Description de la photo
</label> </td>
</tr>
<tr>
<td colspan="2">
<textarea name="message" id="message" title="message" rows="1" cols="40" tabindex="11" style="width: 800px; height: 47px;" onFocus="this.select()" value="<?php if (isset($_POST['message'])) echo htmlentities(trim($_POST['message'])); ?>"></textarea> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<label for="image">Votre image :</label>
<input type="file" name="monfichier" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input style="color: #FFFFFF;border: 1px solid #23568d;font-family:Trebuchet MS, Trebuchet, Verdana, sans-serif;font-size: 14px;background-color: #23568d;" name="submit" type="submit" id="submit" value="Envoyer" />
</div></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</fieldset>
</form> |
Partager