Help on viewing files

  • atlnycdude
  • Newbie
  • Newbie
  • atlnycdude
  • Posts: 6

Post 3+ Months Ago

Okay somehow viewing files are working.
Somehow firefox is being gay when downloading stuff. When i use internet explorer it downloads .doc formats.

It won't do 2007 (.docx) for some stupid reason. Plus it displays jpgs and txt formats.

http://www.hereandhome.org/html/view_files.php

I also don't know why whenever open a document, the download_file.php shows up on the download box.

I want all files to download? What am I doing wrong??

Here is the code for view, download, and the sql query.

view_files.php

Code: [ Select ]
 
   1. <?php
   2.  
   3. $page_title = 'View Files';
   4.  
   5. require_once ('../mysql_connect.php');
   6.  
   7. $first = TRUE;
   8.  
   9. $query ="SELECT upload_id, file_name, ROUND(file_size/1024) AS fs,
  10. DATE_FORMAT(date_entered, '%M %e, %Y') AS d FROM resume ORDER BY date_entered DESC";
  11. $result = mysql_query ($query);
  12.  
  13. while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
  14.  
  15. if($first){
  16.  
  17.     echo'<table border="0" width="100%" cellspacing="3" cellpadding="3" align="center">
  18.     <tr>
  19.         <td align="left" width="20%"><font size="+1">File Name</font></td>
  20.         <td align="center" width="20%"><font size="+1">File Size</font></td>
  21.         <td align="left" width="20%"><font size="+1">Upload Date</font></td>
  22.    
  23.    
  24.     </tr>';
  25.    
  26.     $first = FALSE;
  27.    
  28.     }
  29.    
  30.     echo "<tr>
  31.         <td align=\"left\"><a href=\"download_file.php?uid={$row['upload_id']}\">{$row['file_name']}</a></td>
  32.         <td align=\"center\">{$row['fs']}kb</td>
  33.         <td align=\"left\">{$row['d']}</td>
  34.         </tr>\n";
  35.         }
  36.        
  37.         if($first) {
  38.         echo '<div align="center">There are currently no files to be viewed.</div>';
  39.        
  40.         } else{
  41.        
  42.         echo '</table>';
  43.        
  44.         }
  45.        
  46.         mysql_close();
  47.        
  48. ?>
 
  1.  
  2.    1. <?php
  3.    2.  
  4.    3. $page_title = 'View Files';
  5.    4.  
  6.    5. require_once ('../mysql_connect.php');
  7.    6.  
  8.    7. $first = TRUE;
  9.    8.  
  10.    9. $query ="SELECT upload_id, file_name, ROUND(file_size/1024) AS fs,
  11.   10. DATE_FORMAT(date_entered, '%M %e, %Y') AS d FROM resume ORDER BY date_entered DESC";
  12.   11. $result = mysql_query ($query);
  13.   12.  
  14.   13. while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
  15.   14.  
  16.   15. if($first){
  17.   16.  
  18.   17.     echo'<table border="0" width="100%" cellspacing="3" cellpadding="3" align="center">
  19.   18.     <tr>
  20.   19.         <td align="left" width="20%"><font size="+1">File Name</font></td>
  21.   20.         <td align="center" width="20%"><font size="+1">File Size</font></td>
  22.   21.         <td align="left" width="20%"><font size="+1">Upload Date</font></td>
  23.   22.    
  24.   23.    
  25.   24.     </tr>';
  26.   25.    
  27.   26.     $first = FALSE;
  28.   27.    
  29.   28.     }
  30.   29.    
  31.   30.     echo "<tr>
  32.   31.         <td align=\"left\"><a href=\"download_file.php?uid={$row['upload_id']}\">{$row['file_name']}</a></td>
  33.   32.         <td align=\"center\">{$row['fs']}kb</td>
  34.   33.         <td align=\"left\">{$row['d']}</td>
  35.   34.         </tr>\n";
  36.   35.         }
  37.   36.        
  38.   37.         if($first) {
  39.   38.         echo '<div align="center">There are currently no files to be viewed.</div>';
  40.   39.        
  41.   40.         } else{
  42.   41.        
  43.   42.         echo '</table>';
  44.   43.        
  45.   44.         }
  46.   45.        
  47.   46.         mysql_close();
  48.   47.        
  49.   48. ?>
  50.  



download_files.php

Code: [ Select ]
 
 
# <?php
#  
# if (isset($_GET['uid'])){
# $uid = (int) $_GET['uid'];
#  
# } else {
#  
# $uid = 0;
# }
#  
# if($uid > 0) {
#  
# require_once('../mysql_connect.php');
#  
# $query = "SELECT file_name, file_type, file_size FROM resume WHERE upload_id=$uid";
# $result = mysql_query ($query);
# list ($fn, $ft, $fs) = mysql_fetch_array ($result, MYSQL_NUM);
#  
# mysql_close();
#  
# $the_file = '../uploads/' . $uid;
#  
# if(file_exists($the_file)) {
#  
# header ("Content-Type: $ft\n");
# header ("Content-disposition:
# attachment; filename=\"$fn\"\n");
# header ("Content-Length: $fs\n");
# readfile($the_file);
#  
# } else {
#  
# $page_title = 'File Download';
# echo '<p><font color="red">The file could not be located on the server. We apologize for any inconvenience.</font></p>';
#  
# }
#  
# } else {
#  
# $page_title = 'File Download';
# echo '<p><font color= "red">Please select a valid file to download.</font></p>';
# }
#  
# ?>
 
 
  1.  
  2.  
  3. # <?php
  4. #  
  5. # if (isset($_GET['uid'])){
  6. # $uid = (int) $_GET['uid'];
  7. #  
  8. # } else {
  9. #  
  10. # $uid = 0;
  11. # }
  12. #  
  13. # if($uid > 0) {
  14. #  
  15. # require_once('../mysql_connect.php');
  16. #  
  17. # $query = "SELECT file_name, file_type, file_size FROM resume WHERE upload_id=$uid";
  18. # $result = mysql_query ($query);
  19. # list ($fn, $ft, $fs) = mysql_fetch_array ($result, MYSQL_NUM);
  20. #  
  21. # mysql_close();
  22. #  
  23. # $the_file = '../uploads/' . $uid;
  24. #  
  25. # if(file_exists($the_file)) {
  26. #  
  27. # header ("Content-Type: $ft\n");
  28. # header ("Content-disposition:
  29. # attachment; filename=\"$fn\"\n");
  30. # header ("Content-Length: $fs\n");
  31. # readfile($the_file);
  32. #  
  33. # } else {
  34. #  
  35. # $page_title = 'File Download';
  36. # echo '<p><font color="red">The file could not be located on the server. We apologize for any inconvenience.</font></p>';
  37. #  
  38. # }
  39. #  
  40. # } else {
  41. #  
  42. # $page_title = 'File Download';
  43. # echo '<p><font color= "red">Please select a valid file to download.</font></p>';
  44. # }
  45. #  
  46. # ?>
  47.  
  48.  


The SQL query


Code: [ Select ]
 
 
# CREATE TABLE resume (
#  
# upload_id int(10) UNSIGNED NOT NULL
# AUTO_INCREMENT,
#  
# file_name VARCHAR(1000) NOT NULL,
# file_size INT(255) UNSIGNED NOT NULL,
# file_type VARCHAR(30) NOT NULL,
# date_entered TIMESTAMP,
# PRIMARY KEY (upload_id),
# KEY (file_name),
# KEY (date_entered)
# )
 
 
  1.  
  2.  
  3. # CREATE TABLE resume (
  4. #  
  5. # upload_id int(10) UNSIGNED NOT NULL
  6. # AUTO_INCREMENT,
  7. #  
  8. # file_name VARCHAR(1000) NOT NULL,
  9. # file_size INT(255) UNSIGNED NOT NULL,
  10. # file_type VARCHAR(30) NOT NULL,
  11. # date_entered TIMESTAMP,
  12. # PRIMARY KEY (upload_id),
  13. # KEY (file_name),
  14. # KEY (date_entered)
  15. # )
  16.  
  17.  



Thanks in advance
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • alex89
  • Bronze Member
  • Bronze Member
  • User avatar
  • Posts: 239
  • Loc: Western Australia

Post 3+ Months Ago

Yeah, like, internet explorer sucks ey.

What's the problem? Could you explain a little clearer? What are you trying to do?

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 127 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.