2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by diafol
0

Yes. You need to create loads of icons for each type of file and a blank one for all filetypes not covered. There are loads of free icons out there you can get hold of and chage to your requirements. Be careful - some require a licence or forbid you to use them on a public site.

You can apply the icon to the file via php and css.

1) Copy the file extension from the filename.
2) Paste the extension into a classname for the <li> or whatever you're using to show the filename.
3) Use CSS to indent the text and show a particular image. If the whole thing is made into a download link, you could even create a rollover sprite for the icon, but that's another thing.

$xpos = strpos($filename,'.'); //you'll need to check that this isn't 0
$xpos = $xpos + 1; //this shifts the position along one place
$xt = substr($filename,$xpos); //this reads the extension for the specified position

echo "<li class=\"ext {$xt}\">{$filename}</li>";  //your html output

the css is easy:

.ext{
   text-indent: 20px;
}

.js{
  background: url(/myimages/js.gif) no-repeat;
}
.doc{
  background: url(/myimages/doc.gif) no-repeat;
}
.xls{
  background: url(/myimages/xls.gif) no-repeat;
}

etc. etc.

0

ah thanks sir, so meaning i should one by one filter the file being uploaded then classify it to what type of file is it? thanks sir..

0

You should ALWAYS filter uploads. You won't be able to use my solution unless the file is actually uploaded to a specified folder.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.