Enregistrement image dans un dossier - formulaire

Petit nouveau ! | 3 Messages

04 oct. 2013, 16:35

B :D onjour à tous !

Je souhaiterais à partir d'un formulaire obliger l'enregistrement de deux images sur mon serveur Web
jusqu'à présent une fenêtre s'ouvre et me demande ou je souhaite enregistrer les images ..

Croyez vous que cela soit possible ? #-o


Je vous remercie pour vos conseils ! :mrgreen:

<?php session_start(); ?>
<!doctype html>
<html lang="fr">

<head>

<meta charset="utf-8">

<title>Cr&eacute;ation Signature Outlook </title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="UTF-8" />
<link rel="stylesheet" href="css/template.css" type="text/css" media="screen" title="no title" charset="UTF-8" />

<script src="js/jquery.js" type="text/javascript"></script>	
<script src="js/jquery.validationEngine-fr.js" type="text/javascript"></script>  
<script src="js/jquery.validationEngine.js" type="text/javascript"></script>

<style type="text/css">

a:link{
	text-decoration:none;
	color:#014495;
}
a:visited{
	text-decoration:none;
	color:#014495;
}
a:hover{
	text-decoration:underline;
	color:#999;
}
         .Style1 {
	font-size: 24px;
	font-weight: bold;
}

</style> 

	</head>
	<body>
		
  </br><img src="images/traits.png" alt="" width="100%" height="30" hspace="0" vspace="0" /></p>
  <div id="titre"><img src="images/logo_ars.png" alt=" xxx" width="241" height="154" hspace="0" vspace="0" align="middle" />ignature personnalis&eacute;e <span class="Style1"></span><br />
 
    <br />
    <?php

//header ("Content-type: image/png");
//fichier sources image
//$fichier_source = "images/france.png";
$fichier_source="images/signature_optim.png";
//fichier sources polices
$police="polices/arial.ttf";
//récupération des variables entres dans le formulaire
//Nom,Prenom,Service,Tel,Fax,Email

$nom=$_POST['Nom'];
$prenom=$_POST['Prenom'];
$prenom_nom=$_POST['Prenom']." ".$_POST['Nom'];
$service=$_POST['Service'];
$fonction=$_POST['Fonction'];
$tel="Tel : ".$_POST['Tel'];
//$fax=$_POST['fax'];
$adresse=$_POST['adresse'];

//affichage de la variable de session qui permettra la création d'un dossier 
$_POST['info']=session_id();
echo "La valeur de la variable de session est".$_POST['info'];
error_reporting(0);
mkdir($_POST['info'],777);

echo " </br>"."Après fermeture de votre navigateur IE ou Firefox Il vous sera attribué un nouvel identifiant de session";

// si ajout numero de tel mobile ajout  "Mobile : "
if (!empty($_POST['Mobile']))
{ $mobile="Mobile : ".$_POST['Mobile'];
  }
else
{
$mobile=$_POST['Mobile'];

}
if(!empty($_POST['Fax']))
{
	$fax="Fax : ".$_POST['Fax'];
}
if(!empty($_POST['Mobile'])&& !empty($_POST['Fax']))
{
	echo ("<font face='arial'  color='green'>Attention vous avez rempli les champs</br> fax et mobile veuillez choisir l'un ou l'autre svp ! </font>");
}

$email=$_POST['Email'];
//creation d'une image PNG
$image = @imagecreatefrompng($fichier_source)or die("Création impossible");
//$image = @ImageCreate (200, 100) or die ("Erreur lors de la cration de l'image");
//couleur de fond blanc
$couleur_fond = ImageColorAllocate ($image, 255, 255, 255);
// couleurs Texte blanc, gris, noir
$white = imagecolorallocate($image, 255, 255, 255);
$grey = imagecolorallocate($image, 128, 128, 128);
$black = imagecolorallocate($image, 0, 0, 0);
$green=imagecolorallocate($image,119,139,59);
//taille de la police de caractre
$taille_police=8;
//angle de la police
$angle=0;
//position horizontale Nom
$pos_largeur_nom=65;
//longueur du nom
$longueur=strlen($prenom);

// choix multiple adresse

switch ($adresse){
/*case 68:
echo " </br>Avec Adresse du 68 -";
$adresse_postale="xxxxxxxxxx";

break;
*/
case 67:
$adresse_postale="xxxxxxxxxxxxxxxxxxxxx";
echo " xxxxxxxx   est mentionnée dans la signature  "."</br>";
echo "</br>";
break;
case 0:
//echo " Aucune adresse affichée dans votre signature  ". "</br>";
break;

/* case campagne:
echo " Creation d'une image avec Bandeau";
*/

}
//ajout du texte sur l'image
//variable image, variable taille police,variable angle,position en largeur, position en hauteur
putenv('GDFONTPATH=' . realpath('.'));
imagettftext($image, $taille_police, $angle,5 ,55 , $black, $police,stripslashes($prenom_nom));
imagettftext($image, $taille_police, $angle, 5, 70, $black, $police,  stripslashes($service));
imagettftext($image, $taille_police, $angle, 5, 85, $black, $police,  stripslashes($fonction));
imagettftext($image, $taille_police, $angle, 5, 100, $black, $police, stripslashes($tel));
imagettftext($image, $taille_police, $angle, 115, 100, $black, $police,stripslashes($mobile));
imagettftext($image, $taille_police, $angle, 25, 115, $black, $police, stripslashes($email));

if(!empty($fax)){imagettftext($image, $taille_police, $angle, 115, 100, $black, $police,stripslashes($fax));}
if(!empty($adresse_postale)){imagettftext($image, $taille_police, $angle, 7, 145, $black, $police,$adresse_postale);}

// $temps=time();
$temps='Campagne_Urgence';
$_SESSION['temps']=$temps;
//echo $temps;
echo "</br>";
echo ("<table border=0 hspace=10 vspace=10><tr align=left><td></br> •• > Le nom de votre image sera ".$temps .".png"."</td>
</tr>
<tr align=left>
<td>•• > Le nom de votre fichier html sera ".$temps .".html"."</td>
</tr>
</table></td>");
imagepng ($image,"signatures/".$temps.'.png');
$_SESSION['path']="signatures/".$temps.".png";
//print_r($_SESSION);

?>
    <br />
</div>
<form action="upload.php" method="post" enctype="multipart/form-data" id="sendfile">
  <input type="hidden" name="MAX_FILE_SIZE" value="300000" />
  <br />
  <br />
  <table width="444" border="2" align="center" cellpadding="2" cellspacing="2" id="tableau">
   <tr>
    <td colspan="2" bgcolor="#98BF0E">Aper&ccedil;u Image</td>
    </tr>
  <tr>
    <td colspan="2"  ><img src="<?php echo $_SESSION['path']; ?>" width="100%"  alt="Votre Signature" /></td>
   </tr>
  <tr>
    <td height="43"><br/>
  
  
 <input type="submit" value="Télécharger IMAGE" name="send_image" id="bonton2" />
    <br />
    <br /></td>
    <td><br /><input type="submit" value="Télécharger HTML" name="send_html" id="bonton3" />
     </td>
</tr>
  </table>
  <br />
</form> 
<div id="collage">
  <table width="1076" align="center" cellpadding="2" cellspacing="2" id="tableau">
    <tr>
  <td width="67" height="57" align="center" bgcolor="#FFFFFF"><img src="images/nombre1.png" alt="" width="49" height="49" vspace="5" border="0" align="middle" /></td>
  <td width="997" align="center" valign="middle"><p>T&eacute;l&eacute;charger l'image  l'enregistrer dans
    C:\Documents and Settings\votre login\Application Data\Microsoft\Signatures<br />
( <a href="invisible.php" title="Fichiers cachès" id="lien">Si ce dossier n'est pas visible et pouvoir en afficher le contenu ! Cliquer ici ! </a>)</p></td>
</tr>
    <tr>
      <td height="59" align="center" valign="middle" bgcolor="#FFFFFF"><img src="images/nombre2.png" alt="" width="49" height="49" vspace="5" border="0" align="middle" /></td>
      <td align="center" valign="middle"><p>T&eacute;l&eacute;charger le fichier HTML puis le coller au m&ecirc;me endroit </p>
        <p>! Attention ne pas renommer les fichiers ! <br />
        </p></td>
    </tr>
    <tr>
      <td height="64" align="center" valign="middle" bgcolor="#FFFFFF"><img src="images/nombre3.png" alt="" width="49" vspace="5" border="0" align="absmiddle" /></td>
  <td align="center" valign="baseline">&#8226;&#8226;&#8226;>> <a href="aide.php" title="Aide et explications" id="lien">Configurer Outlook</a> <<&#8226;&#8226;&#8226;<br />
    <br /></td>
</tr>
  </table>
</div>
<div id="pied" height="50"><br />
  | <a href="mailto:xxxx">Contact</a> | <a href="aide.php" title="Aide">Aide</a> |
</p>
</div>
</div>
</body>
<?php 
//génération  du fichier Html
$nom_file=$_SESSION['temps'].'.html';
$_SESSION['nom_file']=$nom_file;
$texte="
<!doctype html>
<html lang='fr'>
<head>
  <meta charset='utf-8'>
  <title>Signature Outlook Personnalisée</title>
</head>
<body><img src='";
$image=$_SESSION['temps'].'.png';
$_SESSION['image']=$image;
$suite="';
</body></html>";
chdir('signatures');

//$f=fopen($nom_file,"x+");
//fputs($f,$texte);
//fputs($f,$image);
//fputs($f,$spc);
//fputs($f,$suite);
//fclose($f);

$upload_dir= "/".$_POST['info'];
move_uploaded_file($path,$upload_dir);
move_uploaded_file($nom_file,$upload_dir);
?>
</html>