1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| <html>
<head>
<title>Uploader</title>
</head>
<body>
<?
if (isset($_POST['upload']))
{
if ($nom == "(facultatif)") { $nom = ""; }
if ($email == "(facultatif)") { $email = ""; }
if ($email != "" && !eregi("^[_\.0-9a-z-]+@([0-9a-z-]+\.)+[a-z]{2,4}$",$email)) { echo "<b>Email non valide ! </b>"; }
for($index=1;$index<=$nbfichier;$index++) {
// Pour enlever les accents ( $_FILES['fichier']['name'][$index-1] remplacé par $dest_fichier)
// Caracteres autres que espace, point, lettres & chiffres remplacés par _
$dest_fichier = basename($_FILES['fichier']['name'][$index-1]);
$dest_fichier = strtr($dest_fichier,'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ','AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
$dest_fichier = preg_replace('/([^ .a-z0-9]+)/i','_',$dest_fichier);
if ( $_FILES['fichier']['error'][$index-1] > 0) { echo "<b>Problème avec le fichier $index (Err.N°".$_FILES['fichier']['error'][$index-1].") </b>"; }
elseif ( file_exists("Upload/Http_Ftp/".$dest_fichier) && $overwrite == "non" ) { echo "<b>Le fichier existe déjà !</b>"; }
elseif ( eregi('.php',$dest_fichier)) { echo "<b>Type de fichier interdit !</b>"; }
else
{ if ( $protocole == "HTTP" )
{
if ( !move_uploaded_file($_FILES['fichier']['tmp_name'][$index-1], "Upload/Http_Ftp/".$dest_fichier))
{ echo "<b>Echec de l'upload via Http !</b>"; $err="mv_upld_file"; }
else
{ echo "<b>Le fichier \"".$_FILES['fichier']['name'][$index-1]."\" a été uploadé ! </b>"; }
}
else
{
$conn_id = ftp_connect("xxxx");
$login_result = ftp_login($conn_id,"xxxx","xxxx");
//ftp_pasv($conn_id, true);
if ((!$conn_id) || (!$login_result))
{ echo "<b>La connexion FTP a échoué !</b>"; $err="cnx ftp"; }
else
{
if (ftp_put($conn_id,"Upload/Http_Ftp/".$dest_fichier,$_FILES['fichier']['tmp_name'][$index-1],FTP_BINARY))
{ echo "<b>Le fichier \"".$_FILES['fichier']['name'][$index-1]."\" a été uploadé !</b>"; }
else { echo "<b>Echec de l'upload via Ftp !</b>"; $err="ftp_put"; }
}
ftp_close($conn_id);
}
} // fin de else
} // fin de foreach
} // fin de if
$nbfichiermax = 6;
if ($nom == "" ) { $nom = "(facultatif)"; }
if ($email == "" ) { $email = "(facultatif)"; }
if (!isset($nbfichier)) { $nbfichier = 2; }
?>
<form method="POST" enctype="multipart/form-data" action="up.php" >
<table width="70%" border="1" rules="none">
<tr>
<td>Votre Nom</td>
<td><input name="nom" type="text" value="<? echo $nom; ?>" title="30 caractères maxi" onfocus="this.style.backgroundColor='#fff9b9'; if (value=='(facultatif)') {value=''}" onblur="this.style.backgroundColor=''; if (value=='') {value='(facultatif)'}" ></td>
</tr>
<tr>
<td>Votre email</td>
<td colspan=2><input name="email" type="text" size="40" maxlength="30" value="<? echo $email; ?>" title="30 caractères maxi" onfocus="this.style.backgroundColor='#fff9b9'; if (value=='(facultatif)') {value=''}" onblur="this.style.backgroundColor=''; if (value=='') {value='(facultatif)'}" ></td>
</tr>
<tr>
<td><br><br>Message...<br><img src="Images/clavier.gif" border="0" onmouseover="this.className='FlipH'" onmouseout="this.className=''"><br>(facultatif)</td>
<td colspan=2><textarea name="message" cols="55" rows="8" wrap="PHYSICAL"><? echo $message; ?></textarea></td>
</tr>
<? for($i=1; $i<=$_POST['nbfichier']; $i++) { echo "<tr><td>Fichier $i</td><!-- <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"15000000\"> -->";
echo "<td colspan=2><input type=\"file\" name=\"fichier[]\" size=\"60\" onfocus=\"this.style.backgroundColor='#fff9b9'\" onblur=\"this.style.backgroundColor=''\" title=\"Quelques Mo maxi\"></td></tr>"; } ?>
<tr>
<td>Options</td>
<td NOWRAP>Nb de fichiers à uploader<br>Ecraser fichier déjà existant<br>Protocole de transfert</td>
<td width="70%">
<? for($i=1; $i<=$nbfichiermax; $i++) { if ($i != $nbfichier)
{ echo " <input type=\"submit\" name=\"nbfichier\" value=$i class=\"bouton\" onMouseOver=\"this.className='boutonOVER';\" onMouseOut=\"this.className='boutonOUT';\">"; } }; ?><br>
<INPUT TYPE="radio" NAME="overwrite" VALUE="non" checked>NON
<INPUT TYPE="radio" NAME="overwrite" VALUE="oui" <? if ($overwrite=="oui") {echo "checked";} ?> >OUI<br>
<INPUT TYPE="radio" NAME="protocole" VALUE="HTTP" checked>HTTP
<INPUT TYPE="radio" NAME="protocole" VALUE="FTP" <? if ($protocole=="FTP") {echo "checked";} ?> >FTP
<?php
$nbfichiermax = 6;
echo "<select name=\"nbfichier\" onchange=\"this.form.submit();\">
<option value=\"\">Nb files</option>";
for($i=1; $i<=$nbfichiermax; $i++) {
if($i == $_POST['nbfichier']) $selected = "selected"; else $selected = "";
echo "<option ".$selected." value=\"".$i."\">".$i."</option>";
}
echo "</select>";
?>
</td>
</tr>
</table>
<input type="submit" name="upload" value="Uploader" class="bouton" onMouseOver="this.className='boutonOVER';" onMouseOut="this.className='boutonOUT';" >
<input type="reset" value="Effacer" class="bouton" onMouseOver="this.className='boutonOVER';" onMouseOut="this.className='boutonOUT';" onClick="window.location.replace('Up.php');">
</form>
</body>
</html> |
Partager