how can i share a file with another user

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simon2x1
    New Member
    • Dec 2008
    • 123

    #1

    how can i share a file with another user

    i have three user A,B and C user A can only see what he uploaded
    in the userpanel page and the for userB and C.i want user A to share
    want he upload with user B alone by clicking a link named share that
    is in front of want user A upload which willnow display in the userpanel
    of user B
    Code:
    userpanel page
    
    <?php
    	$value = "SELECT username FROM account WHERE ID = '{$_SESSION['user_id']}'";
    	$conta = mysql_query ($value) or die('query error');
    	$time = mysql_fetch_array ($conta);
    	$user = $time[username];
    	
    	$data = "SELECT * FROM store WHERE pick = '$user'";
    	$result = mysql_query ($data) or die('query error');
    	//$part = mysql_fetch_array ($result);
    	//$present = $part[objectname];
    	//echo "$present";
    	$count = 0;
    	while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
    	$present = $line[objectname];
    	echo '<table style="width: 250px;">';
    	echo '<tr>';
    	echo"<td>$present";
    	echo '<td><a id="delete" href="deleted.php?userfile=' . $present . '">delete</a>';
    	echo '</tr>';
    	$count++;
    }
    	echo '</table>';
    ?>
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Simon.

    To do this, you'll want to set up an ACL to allow Users to access files.

    Since this will be a many-to-many relationship, you'll need to set up a separate table mapping Users to images. Something along the lines of:

    [code=mysql]
    CREATE TABLE `ACL-UserImage`
    (
    `UserID` BIGINT UNSIGNED NOT NULL
    , `ImageID` BIGINT UNSIGNED NOT NULL
    , UNIQUE KEY `UserID-ImageID`(`UserI D`, `ImageID`)
    , INDEX(`ImageID` )
    );
    [/code]

    When determining whether a User has permission to access the file, check `ACL-UserImage` to see if you can find a match for that User/image combination.

    Comment

    • simon2x1
      New Member
      • Dec 2008
      • 123

      #3
      thank for your answer but it did not solve the problem i need you to tell me what to add to my code that will make it perform the function of sharing files with another user or an adjustment to my code. this is my table
      [code=sql]
      CREATE TABLE `store` {
      `id` INT NOT AUTO_INCREMENT PRIMARY KEY,
      `Objectname` VARCHAR(35) NOT NULL,
      `size` INT NOT NULL
      `pick` VARCHAR(20) NOT NULL,
      } [/code]

      Objectname --- name of object uploaded
      pick---- name of user that upload
      Last edited by pbmods; Jan 14 '09, 11:50 PM. Reason: Added CODE tags.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        To see if a User has permission to view an image:

        Code:
        $db->query("SELECT 1 FROM `ACL-UserImage` WHERE `UserID` = $userID and `ImageID` = $imageID LIMIT 1");
        If the query returns a row, then the User has permission to view the image (because a record exists for that User/Image combination). If it doesn't return any rows, then the User does not have permission to view the image.

        Comment

        Working...