Module extension PHP Upload sous CS5
Posté : 13 juil. 2011, 17:19
Bonjour à tous,
Voila je dois créer une page qui affiche les membres de l'organisme pour lequel je travail, et cette page doit être modifiable,
donc j'ai créer un formulaire
mais j'obtiens une erreur après avoir insérer l'extension sephiroth de dreamweaver PHP Upload voilà ce que cela m'affiche:
Notice: Undefined index: photo in C:\wamp\www\obvrly\php_upload\index.php on line 18
Mon code php de la page index.php:
Je ne comprends pas pourquoi, j'ai vraiment besoin d'un coup de pouce! Merci
Voila je dois créer une page qui affiche les membres de l'organisme pour lequel je travail, et cette page doit être modifiable,
donc j'ai créer un formulaire
Code : Tout sélectionner
mysql_select_db($database_obvrly, $obvrly);
$query_RsTeam = "SELECT * FROM team";
$RsTeam = mysql_query($query_RsTeam, $obvrly) or die(mysql_error());
$row_RsTeam = mysql_fetch_assoc($RsTeam);
$totalRows_RsTeam = mysql_num_rows($RsTeam);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
<link href="../_css/formulaire.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="equipe" id="equipe" class="formulaire">
<table width="60%" border="1" cellpadding="1" cellspacing="2px" class="formulaire">
<tr>
<th width="52%" scope="row">NOM</th>
<td width="48%"><input type="text" name="nom" id="nom" /></td>
</tr>
<tr>
<th scope="row">PRENOM</th>
<td><input type="text" name="prenom" id="prenom" /></td>
</tr>
<tr>
<th scope="row">COURRIEL</th>
<td><input type="text" name="mail" id="mail" /></td>
</tr>
<tr>
<th scope="row">FONCTION</th>
<td><input type="text" name="fonction" id="fonction" /></td>
</tr>
<tr>
<th scope="row">DIPLOMES OBTENUS</th>
<td><input type="text" name="diplome" id="diplome" /></td>
</tr>
<tr>
<th scope="row">ETABLISSEMENT DE FORMATION</th>
<td><input type="text" name="lieu" id="lieu" /></td>
</tr>
<tr>
<th scope="row">PHOTO</th>
<td><input type="file" name="photo" id="photo" /></td>
</tr>
<tr>
<th scope="row"><input type="submit" name="Envoyer" id="Envoyer" value="Envoyer" /></th>
<td><input name="hiddenField" type="hidden" id="hiddenField" value="membre" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($RsTeam);
?>[color=#0000FF][/color]Notice: Undefined index: photo in C:\wamp\www\obvrly\php_upload\index.php on line 18
Mon code php de la page index.php:
Code : Tout sélectionner
<?php
// ---------------------------------------------
// Pure PHP Upload version 1.1
// -------------------------------------------
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",2000000);
define("DESTINATION_FOLDER", "php_upload/avatar");
define("no_error", "sucess.php");
define("yes_error", "error.php");
$_accepted_extensions_ = "jpg,png,gif";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
$_file_ = $HTTP_POST_FILES['photo'];
if(is_uploaded_file($_file_['tmp_name']) && $HTTP_POST_FILES['photo']['error'] == 0){
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "File troppo pesante";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Estensione non valida";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Cartella di destinazione non valida";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
?>
<?php require_once('../Connections/obvrly.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_obvrly, $obvrly);
$query_RsTeam = "SELECT * FROM team";
$RsTeam = mysql_query($query_RsTeam, $obvrly) or die(mysql_error());
$row_RsTeam = mysql_fetch_assoc($RsTeam);
$totalRows_RsTeam = mysql_num_rows($RsTeam);
?>