probleme d'upload d'images
Posté : 09 sept. 2005, 19:28
bonjour,
je débute en php, je suis en train de faire un site avec une interface admin pour charger des photos. J'ai utilisé un code trouvé dans un bouquin mais celui ci ne fonctionne pas, j'aimerais que la photo se copie dans le dossier images/tish et qu'elle soit de la forme tisha + ID
Pouvez-vous m'aider
Quand je vais sur la page et que j'essaie de modifier la photo j'arrive à ce message d'erreur :
Notice: Undefined variable: tisha_name in c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php on line 54
Notice: Array to string conversion in c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php on line 54
Warning: copy(Array): failed to open stream: No such file or directory in c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php on line 54
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php:54) in c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php on line 57
Merci d'avance
je débute en php, je suis en train de faire un site avec une interface admin pour charger des photos. J'ai utilisé un code trouvé dans un bouquin mais celui ci ne fonctionne pas, j'aimerais que la photo se copie dans le dossier images/tish et qu'elle soit de la forme tisha + ID
Pouvez-vous m'aider
<?php require_once('../Connections/toaster.php'); ?>
<?php
$colname_rsrecuptish = "1";
if (isset($HTTP_GET_VARS['tishref'])) {
$colname_rsrecuptish = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['tishref'] : addslashes($HTTP_GET_VARS['tishref']);
}
mysql_select_db($database_toaster, $toaster);
$query_rsrecuptish = sprintf("SELECT * FROM tish WHERE `ref` = '%s'", $colname_rsrecuptish);
$rsrecuptish = mysql_query($query_rsrecuptish, $toaster) or die(mysql_error());
$row_rsrecuptish = mysql_fetch_assoc($rsrecuptish);
$totalRows_rsrecuptish = mysql_num_rows($rsrecuptish);
session_start();
//init des variables
if(!isset($HTTP_SESSION_VARS['statut'])) $statut=""; else $statut=$HTTP_SESSION_VARS['statut'];
if(!isset($HTTP_SESSION_VARS['log'])) $log=""; else $log=$HTTP_SESSION_VARS['log'];
if(!isset($HTTP_GET_VARS['logout'])) $logout=""; else $logout=$HTTP_GET_VARS['logout'];
if(!isset($HTTP_POST_VARS['modifTish'])) $modifTish="non"; else $modifTish=$HTTP_POST_VARS['modifTish'];
if(!isset($HTTP_POST_VARS['auteur'])) $auteur=""; else $auteur=$HTTP_POST_VARS['auteur'];
if(!isset($HTTP_POST_VARS['ID'])) $ID=""; else $ID=$HTTP_POST_VARS['ID'];
if(!isset($HTTP_POST_VARS['ref'])) $ref=""; else $ref=$HTTP_POST_VARS['ref'];
if(!isset($HTTP_POST_VARS['taille'])) $taille=""; else $taille=$HTTP_POST_VARS['taille'];
if(!isset($HTTP_POST_VARS['prix'])) $prix=""; else $prix=$HTTP_POST_VARS['prix'];
if(!isset($HTTP_POST_VARS['description'])) $description=""; else $description=$HTTP_POST_VARS['description'];
if(!isset($HTTP_POST_FILES['tisha'])) $tisha=""; else $tisha=$HTTP_POST_FILES['tisha'];
if(!isset($HTTP_POST_FILES['tishb'])) $tishb=""; else $tishb=$HTTP_POST_FILES['tishb'];
if(!isset($HTTP_POST_FILES['tishc'])) $tishc=""; else $tishc=$HTTP_POST_FILES['tishc'];
if(!isset($HTTP_POST_VARS['nom'])) $nom=""; else $nom=$HTTP_POST_VARS['nom'];
if(!isset($HTTP_POST_VARS['coul'])) $coul=""; else $coul=$HTTP_POST_VARS['coul'];
//----------------------------
if ($logout=="ok")
{
$HTTP_SESSION_VARS['statut']="";//efface le statut
header("Location: login.php");
}
if ($statut != "admin")
{ header("Location: login.php");
}
?>
<?php
if ($modifTish=="ok")
{
//---Mise à jour dans la base
mysql_select_db($database_toaster, $toaster);
$updatetish = "UPDATE tish SET ref='$ref', nom='$nom', coul='$coul', auteur='$auteur', ID='$ID', taille='$taille', prix='$prix', description='$description' ";
if ($tisha!="")
{$updatetish .= ", tisha='$tisha'";}
$updatetish .= "WHERE ref='$ref' ";
mysql_query($updatetish, $toaster) or die(mysql_error());
//----Gestion de la tisha de l'article si elle a était modifiée
if ($tisha!="")
{
copy($tisha,'../images/tish/'.$tisha_name);
}
//----Redirection vers l'écran de Gestion des articles
header("Location: tishgestion.php");
}
?>
<html><!-- InstanceBegin template="/Templates/modeladmin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Document sans titre</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>
<center>
<form name="form1" method="post" action="">
<select name="select">
<option value="tishajout.php">ajout tish</option>
<option value="tishfajout.php">ajout tish f</option>
<option value="stickajout.php">ajout acc</option>
<option value="newsajout.php">ajout news</option>
<option value="sweatajout.php">ajout sweat</option>
<option value="toyzajout.php">ajout toyz</option>
<option value="artistajout.php">ajout artist</option>
<option>Interfac administrateur</option>
</select>
</form>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">Login : <?php echo $log ?>
- Logout : <?php echo "<a href=\"".$HTTP_SERVER_VARS['PHP_SELF']."?logout=ok\">" ?><img src="clic.gif" width="14" height="13" border="0" align="absmiddle">
</a> </font>
<table width="800" height="875" border="0" cellpadding="0" cellspacing="0">
<tr> <!-- InstanceBeginEditable name="modifadmin" -->
<td align="center" valign="top"> <p><strong><font color="#990000" size="5">Modification
tish</font></strong></p>
<form action="" method="post" enctype="multipart/form-data" name="form2">
<table width="589" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="66" height="22">ref</td>
<td width="179"><input name="ref" type="text" id="ref" value="<?php echo $row_rsrecuptish['ref']; ?>"></td>
<td width="344" rowspan="11" valign="top"><p><img src="../images/tish/<?php echo $row_rsrecuptish['tisha']; ?>" alt="" name="tisha" id="tisha"></p>
<p><img src="../images/tish/<?php echo $row_rsrecuptish['tishb']; ?>" alt="" name="tishb" id="tishb"></p>
<p><img src="../images/tish/<?php echo $row_rsrecuptish['tishc']; ?>" alt="" name="tishc" id="tishc"></p></td>
</tr>
<tr>
<td>nom</td>
<td><input name="nom" type="text" id="nom" value="<?php echo $row_rsrecuptish['nom']; ?>"></td>
</tr>
<tr>
<td>coul</td>
<td><input name="coul" type="text" id="coul" value="<?php echo $row_rsrecuptish['coul']; ?>"></td>
</tr>
<tr>
<td>auteur</td>
<td><input name="auteur" type="text" id="auteur" value="<?php echo $row_rsrecuptish['auteur']; ?>"></td>
</tr>
<tr>
<td>prix</td>
<td><input name="prix" type="text" id="prix2" value="<?php echo $row_rsrecuptish['prix']; ?>"></td>
</tr>
<tr>
<td>taille</td>
<td>
<textarea name="taille" cols="50" rows="10" id="taille"><?php echo $row_rsrecuptish['taille']; ?></textarea></td>
</tr>
<tr>
<td>description</td>
Quand je vais sur la page et que j'essaie de modifier la photo j'arrive à ce message d'erreur :
Notice: Undefined variable: tisha_name in c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php on line 54
Notice: Array to string conversion in c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php on line 54
Warning: copy(Array): failed to open stream: No such file or directory in c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php on line 54
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php:54) in c:\program files\easyphp1-8\www\toaster\admin\tishmodif.php on line 57
Merci d'avance