par
cris84100 » 06 janv. 2014, 16:14
bonjour,$j'avoue avoir essayé tout un tas de formules mais sans succès, à chaque fois l'upload se passe bien mais rien dans le dossier images
Techniquement, je pense que je ne suis pas assez calé en php pour pouvoir faire une telle chose.
Merci de votre aide.
Voici le formulaire basique d'envoi de l'avatar et je mets le code php en entier si quel'un peut m'aider..
<html>
<body>
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Transfère le fichier <input type="file" name="avatar" />
<input type="submit" />
</form>
</body>
</html>
<?php
if (isset($_SESSION[$prefix.'logged']) && $_SESSION[$prefix.'logged'] === true)
{
if(isset($_POST['avatar_actif'], $_POST['avatar']))
{
//On vérifie si l'avatar est bon
$avatar_actif = intval($_POST['avatar_actif']);
$avatar = mysql_real_escape_string(htmlentities($_POST['avatar']));
$infos_avatar = getimagesize($avatar);
if($avatar_actif == 1)//si l'on met un nouvel avatar
{
//verif avatar
if($infos_avatar['0'] <= $config['largeur_max_avatar'])
{
if($infos_avatar['1'] <= $config['hauteur_max_avatar'])
{
mysql_query('UPDATE '.$prefix.'membres SET avatar_actif=1, avatar=\''.$avatar.'\' WHERE id='.$_SESSION[$prefix.'id'])or die(mysql_error());
header('location: profil.php?id='.$_SESSION[$prefix.'id']);
}
else
{
echo stop('Erreur : votre image ets trop haute. La hauteur maximale autorisée est de '.$config['hauteur_max_avatar'].' pixels.', 'modifier_profil.php?action=modifier_avatar');
}
}
else
{
echo stop('Erreur : votre image ets trop large. La largeur maximale autorisée est de '.$config['largeur_max_avatar'].' pixels.', 'modifier_profil.php?action=modifier_avatar');
}
}
else//si l'on désactive juste
{
mysql_query('UPDATE '.$prefix.'membres SET avatar_actif=0, avatar=\''.$avatar.'\' WHERE id='.$_SESSION[$prefix.'id'])or die(mysql_error());
header('location: profil.php?id='.$_SESSION[$prefix.'id']);
}
}
?>
bonjour,$j'avoue avoir essayé tout un tas de formules mais sans succès, à chaque fois l'upload se passe bien mais rien dans le dossier images
Techniquement, je pense que je ne suis pas assez calé en php pour pouvoir faire une telle chose.
Merci de votre aide.
Voici le formulaire basique d'envoi de l'avatar et je mets le code php en entier si quel'un peut m'aider..
[html]<html>
<body>
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Transfère le fichier <input type="file" name="avatar" />
<input type="submit" />
</form>
</body>
</html>
[/html]
[php]<?php
if (isset($_SESSION[$prefix.'logged']) && $_SESSION[$prefix.'logged'] === true)
{
if(isset($_POST['avatar_actif'], $_POST['avatar']))
{
//On vérifie si l'avatar est bon
$avatar_actif = intval($_POST['avatar_actif']);
$avatar = mysql_real_escape_string(htmlentities($_POST['avatar']));
$infos_avatar = getimagesize($avatar);
if($avatar_actif == 1)//si l'on met un nouvel avatar
{
//verif avatar
if($infos_avatar['0'] <= $config['largeur_max_avatar'])
{
if($infos_avatar['1'] <= $config['hauteur_max_avatar'])
{
mysql_query('UPDATE '.$prefix.'membres SET avatar_actif=1, avatar=\''.$avatar.'\' WHERE id='.$_SESSION[$prefix.'id'])or die(mysql_error());
header('location: profil.php?id='.$_SESSION[$prefix.'id']);
}
else
{
echo stop('Erreur : votre image ets trop haute. La hauteur maximale autorisée est de '.$config['hauteur_max_avatar'].' pixels.', 'modifier_profil.php?action=modifier_avatar');
}
}
else
{
echo stop('Erreur : votre image ets trop large. La largeur maximale autorisée est de '.$config['largeur_max_avatar'].' pixels.', 'modifier_profil.php?action=modifier_avatar');
}
}
else//si l'on désactive juste
{
mysql_query('UPDATE '.$prefix.'membres SET avatar_actif=0, avatar=\''.$avatar.'\' WHERE id='.$_SESSION[$prefix.'id'])or die(mysql_error());
header('location: profil.php?id='.$_SESSION[$prefix.'id']);
}
}
?>[/php]