Advertisement

09.14.2008 at 07:05PM PDT, ID: 23730789
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Trying to make SECURE account file upload/download. Files out side of root directory.

Asked by qrpike in Internet File Sharing Software, HTTP, WebApplications

Tags: , ,

Okay, first off, i have spent ALL weekend trying to figure this out.

I am making a site where someone can make an account, and can upload and download there files. Users only able to see their files.

root:
C:/wamp/www/

User files:
C:/wamp/users/

I have accomplished the following:
created account creation page, which registers the user in the DB, and creates a folder in the (Users) folder called there user id#

i have a page called list_dir.php in the root directory of the site. which goes ^up^ one directory and into users. (../users/) and goes into that persons user id folder.

the list_dir.php displays all the files in that folder correctly.

THE PROBLEM:
when i make a direct link to the file, it says it does not exist. When i make a readfile() i can successfully download .txt files, .exe files, but when i try to download JPG files, its "corrupt".

ive tried ALL the (header) files, and all those long code snippets. i much rather use a simple link, like the one in my code snippet.

My basic goal is making a SECURE way to upload and download files for each user, and not being able to access the files via a URL.

im not sure if there is some code to put in the apache config folder.

i REALLY need to get this part of the site complete.

Specs:
Windows server 2003
Apache
MySQL
PHP 5

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
<?php
// This script lists the directories and files in a directory.
session_start();
// Address error handing.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
 
$search_dir = realpath("../users/" . $_SESSION['id']);
$dirPath = ($search_dir);
 
// open the specified directory and check if it's opened successfully 
if ($handle = opendir($dirPath)) {
/*header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");*/
   // keep reading the directory entries 'til the end 
   while (false !== ($file = readdir($handle))) {
 
      // just skip the reference to current and parent directory 
      if (($file != "." && $file != "..") && (substr ($file, 0, 1) != '.')) {
         if (is_dir("$dirPath/$file")) {
            // found a directory, do something with it? 
            echo "Directory: $file<br>";
         } else {
			echo "<a href=\"../users/{$_SESSION['id']}/$file\">$file</a><br />";
			
             
		
         }
      }
   }
 
   // ALWAYS remember to close what you opened 
   closedir($handle);
}
}
?>
[+][-]09.16.2008 at 12:59PM PDT, ID: 22492607

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Internet File Sharing Software, HTTP, WebApplications
Tags: PHP, All? Safari, firefox, IE, chrome, N/A
Sign Up Now!
Solution Provided By: dereck2008
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628