| [ Index ] |
PHP Cross Reference of IEUF |
[Summary view] [Print] [Text view]
1 <?php 2 //Vérification accès 3 require 'inc/autorisation.inc.php'; 4 if (NonCA()) include 'inc/404.php'; 5 include "../inclus/connect_bdi.inc.php"; 6 $max_file=4096*1024; 7 $rep="../media/depliant/"; 8 ?> 9 <!DOCTYPE html> 10 <html> 11 <head> 12 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> 13 <title> Chargement d'un dépliant </title> 14 <link rel="stylesheet" href="formulaire.css" type="text/css"> 15 <style type="text/css"> 16 body { 17 background-color: #999999; 18 margin: 0px; 19 } 20 h3 { 21 margin: 0px; 22 margin-top: 10px; 23 text-align: center; 24 } 25 output { 26 position: absolute; 27 top: 140px; 28 font-size: 12pt; 29 } 30 </style> 31 32 </head> 33 <body> 34 <?php 35 if (isset ($_POST['nomfic'])) { 36 echo "<pre>"; 37 print_r ($_POST); 38 print_r ($_FILES); 39 echo "</pre>"; 40 if ($_FILES['fichier']['error'] != 0) { 41 echo "erreur n°".$_FILES['fichier']['error']; 42 exit; 43 } 44 move_uploaded_file($_FILES['fichier']['tmp_name'], $rep.$_POST['nomfic'].'.pdf'); 45 echo "ça baigne !"; 46 echo "<script> 47 window.opener.inser_media('".$_POST['nomfic']."'); 48 window.close(); 49 </script>"; 50 exit; 51 } 52 ?> 53 <div class="panneaux" style="height: 170px; margin-top: 5px; width: 160px; font-size: 8pt; overflow: auto"> 54 <h3>Dépliants sur le site</h3> 55 <?php 56 foreach (glob("$rep*.pdf") as $nomfic) { 57 $nom=substr($nomfic, strlen($rep), strlen($nomfic)-strlen($rep)-4); 58 echo "$nom\r\n<br>"; 59 } 60 ?> 61 </div> 62 <div class="panneaux" style="height: 170px; margin-top: 5px; left: 190px; width: 380px; font-size: 8pt; overflow: auto"> 63 <h3>Choix du dépliant en local <span style="font-weight: lighter;"> (fichier PDF, taille < <?php echo $max_file/1024; ?> Ko)</span></h3> 64 <form enctype="multipart/form-data" name="media" id="media" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> 65 <input name="MAX_FILE_SIZE" value="<?php echo $max_file; ?>" type="hidden"> 66 <input type="file" name="fichier" id="fichier" accept="application/pdf" size="43" onchange="verif_file()" style="width: 200px;"><br> 67 <h3>Nom à donner au dépliant sur le site</h3> 68 <input type="text" name="nomfic" pattern="[0-9A-Za-z\-_]+" autofocus onkeyup="verif_nom()">.pdf <span id="existant" style="color: red"></span><br> 69 <span>(lettres, chiffres, tiret, souligné)</span> 70 </form> 71 <output id="taille"> 72 </output> 73 74 </div> 75 <iframe class="panneaux" id="visu" style="height: 170px; margin-top: 5px; left: 600px; width: 270px; font-size: 8pt; overflow: auto; border: none;"> 76 </iframe> 77 <div style="position:absolute; width: 80%; left: 10%; bottom:0px;"> 78 <p style="text-align: center"> 79 <input id="valide" type="submit" value="Valider" disabled="disabled" form="media"> 80 <input type="button" value="Annuler" onclick="self.close()"> 81 </p> 82 </div> 83 <script type="text/javascript"> 84 fic_ok= false; 85 visu = new FileReader(); 86 visu.onloadend = function(e) { 87 elt=document.getElementById("visu"); 88 elt.src=e.target.result; 89 } 90 91 tab_nom=[]; 92 <?php 93 $i=0; 94 foreach (glob("$rep*.pdf") as $nomfic) { 95 $nom=substr($nomfic, strlen($rep), strlen($nomfic)-strlen($rep)-4); 96 echo "tab_nom[$i]='$nom';\r\n"; 97 $i++; 98 } 99 ?> 100 101 function verif_file() { 102 fic=document.getElementById("fichier").files[0]; 103 message=""; 104 fic_ok= false; 105 document.getElementById("visu").src= ""; 106 document.getElementById("taille").innerHTML= ""; 107 document.getElementById("valide").disabled=true; 108 if (fic.size> <?php echo $max_file; ?>) message="Ce fichier est trop gros\n"; 109 if (fic.type!= "application/pdf") message+="Le fichier doit être de type PDF"; 110 if (message !="") alert (message); 111 else { 112 fic_ok= true; 113 document.getElementById("taille").innerHTML="Taille : "+Math.floor(fic.size/1024)+ " Ko"; 114 if (document.media.nomfic.value != "") document.getElementById("valide").disabled=false; 115 visu.readAsDataURL(fic); 116 } 117 } 118 function verif_nom() { 119 var nom=document.media.nomfic.value; 120 document.getElementById("valide").disabled= !(fic_ok && nom !=""); 121 document.getElementById('existant').innerHTML=""; 122 for (var i=0; i<tab_nom.length; i++) 123 if (nom==tab_nom[i]) { 124 document.getElementById('existant').innerHTML='Attention, vous allez écraser le fichier'; 125 break; 126 } 127 } 128 </script> 129 </body> 130 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 31 19:59:00 2014 | Cross-referenced by PHPXref 0.7.1 |