Jump to content

Allocating the user by the session as a file upload


R0xxy

Recommended Posts

i have my upload process working that uploads documents to the server and then displays in onto the user page like this:

<?php 
						function find_all_files($dir) 
						{ 
    							$root = scandir($dir); 
    							foreach($root as $value) 
    							{ 
    				    				if($value === '.' || $value === '..') {continue;} 
        							if(is_file("$dir/$value")) {$result[]="$dir/$value";
        							continue;
        							} 
        							foreach(find_all_files("$dir/$value") as $value) 
        							{ 
           							 $result[]=$value; 
       								 } 
	   					 	} 
  					 		 return $result; 
						} 
							$fileupload = 'fileupload';
							$getem = find_all_files($fileupload);
							foreach($getem as $key => $value)
							{
								echo '<a href="'.$value.'">'.$value.'</a><br />';
							}
						?>
						
						
						
						<?php
						if($handle = opendir('members/')) {
						while (false !== ($entry = readdir($handle))) {
							if($entry != "." && $enrty != "..") {
							echo "<a href='download.php?file=".$entry."'>".$entry."</a>\n";
							}
							}
							closedir($handle);
							}
							?>

here they can download the files to their computer however is there a way to only display the file of the user that is logged in through their session?

 

 

 

Link to comment
Share on other sites

I don't get your script.  First you call your function to dump all the files in the specified directory and sub-directories of it.  Then you open a different directory and dump the filenames and dirnames in that ONE folder.  And - is this a sample of your upload process or is that a completely separate process that doesn't need mentioning here?  (Plus - you have a typo in this code that s/b giving you an error, if you have error checking turned on properly.)

 

As for your question - I am assuming that you have a user logged in who has a session var that indicates such and you want to tie that user to a group of files so you can only show him 'his files'.  If so - you have to do something to make that connection during the upload.  How are you envisioning that?  Does your upload process only allow them to put files in one place, based on their login value?  Does your upload process create an entry in a db table to record what files each user uploads?  To answer your question - I would say yes you can do this but it's not done by magic - you have to create something to make it possible.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.