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? Quote Link to comment 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>"; } ?> Quote Link to comment 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'; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.