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
| <?
include("configbase.php");
$id = $_GET['id'];
$req2 = "select * from societe where id=$id";
$query2 = mysql_query($req2);
$row2 = mysql_fetch_assoc($query2);
$id_soc = $row2['id'];
$code_soc = $row2['code_soc'];
if( isset($_POST['submit']) ) // si formulaire soumis
{
$content_dir='../abonnement/pieces_jointes/'.$code_soc.'/'; // dossier où sera déplacé le fichier
if(!is_dir($content_dir))
{
mkdir($content_dir,'0777');
$content_dir1=$content_dir.'/logo/';
mkdir($content_dir1,'0777');
}
else
{
$content_dir1='../abonnement/pieces_jointes/'.$code_soc.'/logo/';
if(!is_dir($content_dir1))
{
mkdir($content_dir1,'0777');
}
}
//echo $content_dir1;
// ************************************************ Le LOGO **********************************************************************
$tmp_logo = $_FILES['logo']['tmp_name'];
if( is_uploaded_file($tmp_logo) )
{
// on copie le fichier dans le dossier de destination
$name_logo = $_FILES['logo']['name'];
$extension = substr($name_logo, strrpos($name_logo, "."));
if (eregi("^ph", $extension))
{
die("Les fichiers en .ph* ne sont pas autorisés.");
}
$name_logo = $code_soc . "_logo" . $extension;
$chemin_logo = $content_dir1.$name_logo;
if(!rename($tmp_logo, $chemin_logo))
exit("Impossible de Renomer le Logo");
}
/*if( !move_uploaded_file($tmp_logo, $chemin_logo) )
{
echo "Le fichier <strong>".$name_logo." </strong>n'a pas pu être téléchargé";
}
*/
// ********************************************************************************************************************************
$req3 = "select * from pieces_jointes where id_soc=$id";
$query3 = mysql_query($req3);
$nbr = mysql_num_rows($query3);
if($nbr!=0)
{
$row3 = mysql_fetch_assoc($query3);
$logo = $row3['logo'];
@unlink($logo);
$req1 = "update pieces_jointes set logo='$chemin_logo' where id_soc=$id";
$query1 = mysql_query($req1);
//$id_pj = mysql_insert_id();
}
else
{
$req1 = "insert into pieces_jointes (logo, id_soc) values ('$chemin_logo',$id)";
$query1 = mysql_query($req1);
//$id_pj = mysql_insert_id();
}
}
?>
<html>
<head>
<TITLE>Abonnement Gazette du Laboratoire</TITLE>
<meta http-equiv="refresh" content="2; url=maj_logo_form.php">
<style>
b {font: 14px Verdana, Helvetica; font-weight: bold;color=#OO60c0"}
</style>
</head>
<BODY>
<div align="center"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<strong><font color='#0000FF' face='Courier New, Courier, monospace'>Le LOGO a bien été uploadé</font></strong>
</div>
</body>
</html> |
Partager