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?

 

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.