metalhead41 Posted February 17, 2008 Share Posted February 17, 2008 I have an upload/download script working, I have one tiny little question though... I know I can set php to only accept certain files, is there a way I can get it to append an image to the list of downloads depending on what file type it is? Link to comment https://forums.phpfreaks.com/topic/91541-download-question/ Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 Yes, you could try something like: <?php $file = "image.gif"; //The file $imageTypes = array("image/png", "image/jpeg", "image/gif"); if( in_array("mime_content_type('$file')", $imageTypes) ) { echo "<a href=\"path/$file\"> download </a>"; } ?> Link to comment https://forums.phpfreaks.com/topic/91541-download-question/#findComment-468915 Share on other sites More sharing options...
metalhead41 Posted February 17, 2008 Author Share Posted February 17, 2008 Just tried this, but it doesn't seem to want to work. This is my current code: <?php include 'library/config.php'; include 'library/opendb.php'; $query = "SELECT id, name FROM upload"; $result = mysql_query($query) or die('Error, query failed'); if(mysql_num_rows($result) == 0) { echo "Database is empty <br>"; } else { while(list($id, $name) = mysql_fetch_array($result)) { { echo "got filename from db<br />"; } ?> <a href="download.php?id=<?=$id;?>"><?=$name;?></a><br /> <?php } } include 'library/closedb.php'; ?> Link to comment https://forums.phpfreaks.com/topic/91541-download-question/#findComment-468970 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.