Help on viewing files
- atlnycdude
- Newbie


- Joined: Dec 30, 2008
- Posts: 6
- Status: Offline
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
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. ?>
download_files.php
# <?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>';
# }
#
# ?>
The SQL query
# 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)
# )
Thanks in advance
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. <?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. ?>
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>';
# }
#
# ?>
- # <?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>';
- # }
- #
- # ?>
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)
# )
- # 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)
- # )
Thanks in advance
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
December 30th, 2008, 6:38 pm
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 2 posts
- Users browsing this forum: No registered users and 148 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

