$res_copy = true;
if(!empty($HTTP_POST_FILES['fic_info']['name']))
{
$dossier_destination="fichier";
if($dossier_destination=="" || !is_dir($dossier_destination))
{
echo "<h3>dossier de destination non renseigné ou inexistant</h3>";
exit();etc...DEFINE("PATH_IMAGES", WEBROOT."/images/"); // chemin des images
Merci.
if($dossier_destination=="" || !is_dir($dossier_destination))Sous cette forme, en tout cas.
Code : Tout sélectionner
<a target='_blank' href='".$item["telecharger"]."'><img src='./images/download.gif' title='Telecharger' style='border-color:white'/></a>$chemin_fichier = '/dossier/mon.fichier.pdf';
$tab = explode('.',$chemin_fichier);
$extension = $tab[count($tab) - 1];
On obtient l'extension (count nous sert pour obtenir la taille du tableau - notre extension étant dans la dernière case - et le (-1) est là car un tableau commence à l'index 0).if( $extension === "pdf" )
echo '<img src="./images/download-pdf.gif" title="Telecharger" style="border-color:white"/>'; // .pdf
else if( $extension === "doc" || $extension === "docx" )
echo '<img src="./images/download-doc.gif" title="Telecharger" style="border-color:white"/>'; // .doc OU .docx
else
echo '<img src="./images/download.gif" title="Telecharger" style="border-color:white"/>'; // extension non connue on affiche une image par défaut
Voilà le principe.
<?php
switch ($extension)
{ case 'pdf' : $image='download-pdf.gif'; break;
case 'doc' :
case 'docx' : $image='download-doc.gif'; break;
default : $image='download.gif'; break;
}
?>
<img src="./images/<?php echo $image; ?>" title="Telecharger" style="border-color:white"/>
function Exercice_Creation($dom) //Cree la liste des exercices
{
foreach($dom as $sous_dom=>$exercice)
{
$html .= "<div id=\"titre2\"><h2>$sous_dom</h2></div>"; //Affiche le nom du sous domaine
$html .= "<ul>";
foreach($exercice as $item) //Affiche tout les exercices D'abord visualiser, ensuite telecharger.
{
$html.="<div id=\"News_exe\">
<table>
<tr>
<td width='400px'>
<a target='_blank' href='".$item["lien"]."'>".$item["lib"]."</a>
</td>
<td width='20px'>
<a target='_blank' href='".$item["telecharger"]."'><img src='./images/download.gif' title='Telecharger' style='border-color:white'/></a>
switch ($extension)
{ case 'pdf' : $image='download-pdf.gif'; break;
case 'doc' : $image='download-doc.gif'; break;
default : $image='download.gif'; break;
}
<img src="./images/<?php echo $image; ?>" title="Telecharger" style="border-color:white"/>
</td>
</tr>
</table>
</div>";
}
$html .= "</ul><br>";