payetonju
Messages postés436Date d'inscriptionmercredi 26 septembre 2007StatutMembreDernière intervention 2 juillet 2014
-
8 janv. 2010 à 13:06
payetonju
Messages postés436Date d'inscriptionmercredi 26 septembre 2007StatutMembreDernière intervention 2 juillet 2014
-
8 janv. 2010 à 13:53
Bonjour, je suis assez embeté, mon input file ne marche pas, il ne me renvoit rien, je me prends al tete depuis ce matin, je comprends pas ce qu'il se passe, est ce que quelqu'un peu m'aider svp ?
voici ma page :
<?php
include_once('fonctions-systemes.php');
include_once('constantes.php');
if( !isset( $_SESSION['login'] ) )
{
header("location:/index.php");
exit();
}
$SessionLogin = $_SESSION['login'];
$Conn = mysql_connect($host,$user,$pwd);
mysql_select_db($bdd,$Conn) or die ("ERREUR");
$sql "select EXTENSION from utilisateurs where LOGIN '".$SessionLogin."' ";
$res = mysql_query($sql) or die('Erreur SQL !
'.$sql.'
'.mysql_error());
$NumRows = mysql_num_rows($res);
while($data = mysql_fetch_assoc($res))
{
$ExtensionBase = $data['EXTENSION'];
}
mysql_close($Conn);
echo "9
";
if( $_FILES['inser'] )
{
echo "0
";
if( $_FILES['inser']['name'] != "" )
{
echo "1
";
$NomPhoto = $_FILES['inser']['name'];
// renvoi 'image/gif' ... donc on prend 'image' et si les 5 premiers caracteres du type ne forment pas "image" c'est que ce n'est pas une image
if(substr($_FILES['inser']['type'],0,5) != 'image')
{
$ErreurPhoto = "
Format de photo non supporté ! ";
break;
}
elseif($_FILES['inser']['size'] > '50000')
{
$SizeEnTropKo = ($_FILES['inser']['size'] - 50000)/1024;
$SizeEnTropKo = sprintf('%.02f',$SizeEnTropKo);
$TailleKo = $_FILES['inser']['size']/1024;
$TailleKo = sprintf('%.02f',$TailleKo);
$ErreurPhoto = "
Taille trop importante, tu es ".$SizeEnTropKo."Ko en trop. [".$TailleKo."Ko]";
break;
}
else
{
// on remplace certains caractères spéciaux par leur correspondant en ASCII - Caractère normal autorisé pour l'enregistrement correct du fichier
$NomPhoto = strtr($NomPhoto, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
//on remplace chacun de ces caractères par '_'
$NomPhoto = preg_replace('/([^.a-z0-9]+)/i', '_', $NomPhoto);
// on remplace les espaces que peuvent contenir les fichiers par '_'
$NomPhoto = str_replace(" ", "_", $NomPhoto );
$CheminPhoto = "../".$CheminMembres.$PostLogin."/";
if(!is_dir($CheminPhoto))
{
mkdir($CheminPhoto);
}
//Copie dans le repertoire du script
if(move_uploaded_file($_FILES["inser"]["tmp_name"], $CheminPhoto.$NomPhoto))
{
$ElementsPhoto = pathinfo($NomPhoto);
$Extension = $ElementsPhoto['extension'];
rename($CheminPhoto.$NomPhoto, $CheminPhoto."profil.".$Extension);
}
else
{
echo "Le fichier n'a pas été uploadé (trop gros ?) ou ". "Le déplacement du fichier temporaire a échoué" - " ";
echo "vérifiez l'existence du répertoire ".$CheminPhoto."";
}
$Conn = mysql_connect($host,$user,$pwd);
mysql_select_db($bdd,$Conn) or die ("ERREUR");
$sql "update utilisateurs set PHOTO 1, EXTENSION = '".$Extension."' ";
$ErreurPhoto = "Photo téléchargée avec succès.";
$Tag = "ok";
}
}
else
{
$ErreurPhoto = "Euh... avec une photo ça serait mieux, nan ?";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><!-- InstanceBegin template="/Templates/template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Modifier sa photo</title>
<!-- InstanceEndEditable -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/includes/menu.css" rel="stylesheet" type="text/css">
<link href="/includes/style-general.css" rel="stylesheet" type="text/css">
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
(CLIQUEZ-ICI
si vous voulez etre redirigé
vers l'ancienne page d'accueil)
<form action="/connexion.php" method="POST" name="log" id="log"><?php include_once('menu.php'); ?></form>,
----
<!-- InstanceBeginEditable name="Corps" -->
<form name="modif" id="modif" action="modif_photo.php" method="post"><center>
MODIFICATION DE TA PHOTO DE PROFIL
<table width="90%" height="235" border="0" cellpadding="0" cellspacing="0" style="font-size:13px;">
----, Modifie une photo de toi : ( 50Ko maxi)
(Formats conseillés : *.JPG ou *.GIF)</td>
----
<?php if( isset( $ErreurPhoto ) && $ErreurPhoto ! = "" ) echo $ErreurPhoto; ?>
<?php
if( isset( $NomPhoto ) && $NomPhoto != "" )
{
echo "Photo actuelle :
";
}
elseif( isset( $ExtensionBase ) && $ExtensionBase != "" )
{
echo "Photo actuelle :
";
}
else
{
echo "ERREUR !!!!!!";
}
?>
</center>
</form>
<!-- InstanceEndEditable --></td>
</tr>
</table>
<!-- InstanceEnd --></html>
Pour mes tests, j'ai fais un ECHO de 9, un ECHO de 0, puis un ECHO de 1, seul le 9 s'affiche mais pas le 0 ni le 1.