Bonjour,
je suis plus que debutant, un capable d'ecrire un bout de code sans me servir des sources.
voila mon probleme: j'ai ce bout de code et il me modifie le nom du fichier quand il l'upload.
si une âme genereuse pouvait le modifie, j'en serais tres comptant et merci pour vos reponses.
code source de abamalcolmix
Code PHP :
<?php
include('config.php');
$an = date("Y");
$mois = date("m");
$day = date("d");
function getName($pre='',$post='')
{
$name=time();
$name=str_replace(array(' ','.'),'',$name);
$cle=mt_rand(0,9);
return $pre.$name.$cle.'.'.$post;
}
if(isset($_POST['submit']))
{
if($_FILES['fichier']['size']>$poids_max)
{
$message='Le fichier est trop lourd !';
}
else
{
$extension_upload=substr(strrchr($_FILES['fichier']['name'], '.') ,1);
if(in_array($extension_upload,$extensions_autorisees))
{
$nom=getName('sons/',$extension_upload);
move_uploaded_file($_FILES['fichier']['tmp_name'],$nom);
$message='Votre fichier a bien été uploadé. Il est disponible à l\'adresse suivante :<br /><a href="'.$url_site.$nom.'">'.$url_site.$nom.'</a><br /><a href=\'upload.php\'>Retour à la page d\'upload</a>';
$description = nl2br(stripslashes($_POST['description']));
$nom2 = htmlentities($_POST['nom'], ENT_QUOTES);
mysql_query("INSERT INTO download VALUES('','" . $nom . "','".$description."','".$url_site.$nom."','".$an."/".$mois."/".$day."')") or die ("Un probléme :".mysql_error());
}
else
{
$message='L\'extension n\'est pas autorisée';
}
}
echo $message;
}
else
{
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Upload de sons</title>
</head>
<link rel="stylesheet" media="screen" type="text/css" title="design_index_html.css" href="design_index_html.css" />
<body>
<div id="en_tete"><img src="images/serveur d'images.png" /></div>
<div id="corps" style="width: 500px" align="center";>
<form method="post" action="" enctype="multipart/form-data">
<label for="fichier"><strong>Fichier (Poids max. : 10 Mo)</strong></label>
<strong><br /><br />
<input type="hidden" name="MAX_FILE_SIZE" value="104857600" />
<input type="file" name="fichier" id="fichier" size="30" />
<br /><br />
<label>Nom
<input name="nom" type="text" id="nom" />
</label><br /><br />
<label>Description</label>
</strong>
<label>
<textarea name="description" id="description"></textarea>
</label>
<br /><br />
<input type="submit" name="submit" value="Envoyer" />
</form></div>
<div id="wrap">
<div id="main" class="clearfix">
</div>
</div>
<div id="footer">
</div>
<div id="pied_de_page">
Copyright "Corporation Open Sources" 2009, tous droits réservés
</div>
</body>
</html>
<?php
}
?>