en fait voici le code du formulaire...et le type de fichier a uploader est doc, pdf, txt.
<form action="" method="post" enctype="multipart/form-data" name="form1">
<FONT face=Verdana color=#000066><B>Vous désirez prendre contact avec nous ? Merci d'utiliser le formulaire suivant pour nous envoyer votre message. Nous pourrons ainsi vous répondre dans les meilleurs délais. </B></FONT><br>
<br>
<table width="405" align="center">
<tr>
<td><B><FONT color="#000066" class=small>Nom / prenom </FONT></B></td>
<td><input type="text" name="textfield"></td>
</tr>
<tr>
<td><B><FONT color="#000066" class=small>Email : </font></B></td>
<td><input type="text" name="textfield"></td>
</tr>
<tr>
<td><font color="#000066"><B><FONT
class=small>Société :</FONT></B></font></td>
<td><input type="text" name="textfield"></td>
</tr>
<tr>
<td><strong><font color="#000066">Site web : </font></strong></td>
<td><input type="text" name="textfield"></td>
</tr>
<tr>
<td><font color="#000066"><B><FONT
class=small>Téléphone :</FONT></B></font></td>
<td><input type="text" name="textfield"></td>
</tr>
<tr>
<td><font color="#000066"><B>Piece jointe </B></font></td>
<td><input type="file" name="file"></td>
</tr>
<tr>
<td valign="top"><font color="#000066"><strong>Message </strong></font></td>
<td><textarea name="textarea" cols="30" rows="7"></textarea></td>
</tr>
<tr>
<td valign="top"><font color="#000066"> </font></td>
<td><input type="submit" name="Submit" value="Envoyer"></td>
</tr>
</table>
<br>
</form>
concernant le code php : <?php require_once('../Connections/contact.php'); ?>
<?php
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",300000);
define("DESTINATION_FOLDER", "C:\Documents and Settings\hanlin\Bureau\societe\manyee site\contacter\docs");
define("no_error", "valider.php");
define("yes_error", "erreur.php");
$_accepted_extensions_ = "doc,pdf,txt,";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
/* modify */
if(!empty($HTTP_POST_FILES['file'])){
if(is_uploaded_file($HTTP_POST_FILES['file']['tmp_name']) && $HTTP_POST_FILES['file']['error'] == 0){
$_file_ = $HTTP_POST_FILES['file'];
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "fichier trop volumineux";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "extension non valide
}
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);
}
}
}
?>
