0

Hi

I have a problem that I'm not sure how to resolve. My issue is that I have to setup a page that allows coworkers at my office to be able to upload meeting documents and such. They should be able to upload them themselves and the user viewing the document should be able to download them to their computer. The user on the other should not be able to upload documents. Should I just create a folder in ftp and then create a script to let only certain people logged on upload documents? Not sure how to go about this. I want to make it very easy for them to upload the documents.

Thanks

5
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by 84hd0ns
0

I think you easily use google docs since making permission for each user would be a drag unless you have a word press based website ...

0

You need a php uploader, password controlled, and preferably only those who do the uploading know the page even exists. If they upload to a folder with no index page and your server shows the folder contents when there is no index page, then everyone can see the documents to download them, so everything becomes available to everyone. You could separate things on a topic by topic basis by having the destination folder dependant on who does the uploading, or rather who they say they are. I wrote such a script for a client a while ago.

0

Hello,

Try this in php:

<?php
//The password
$password = '123abc';
?>
<ul>
<?php
if ($handle = scandir('docs/')) {
   foreach ($handle as $file)
   {
          if ($file != "." && $file != ".." && $file != ".htaccess")
	  {      
          	
		$doc .= '<li><a href="docs/'.$file.'">'.$file.'</a></li>';
          }
       }
  }

print $doc;
?>
</ul>

<?php if($_GET['action'] == 'upload'){
print '<form action="'.$_SERVER["PHP_SELF"].'?action=chkpw" method="post">
  <p>To upload a file you need to enter your password.</p>
  Password: <input type="password" name="pw" /><br />
  <input type="submit" value="Submit" />
</form>';}
?>

<?php if($_GET['action'] == 'chkpw'){

if($_POST['pw'] == $password){
print '<p>Please Choose a file to upload.<br /></p>';
print '
<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'?action=uploadfile" method="post">
<input type="file" name="uploaded" /><br />
  <input type="hidden" name="password" value="'.$_POST["pw"].'" />
  <input type="submit" value="Submit" />
</form>
';
}
else {print '<p>Wrong Password</p>';}

} 

if($_GET['action'] == 'uploadfile' && $_POST['password'] == $password){

$target = "docs/"; 
 $target = $target . basename( $_FILES['uploaded']['name']) ; 
 $ok=1; 
 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
 {
 echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
 } 
 else {
 echo "Sorry, there was a problem uploading your file.";
 }

}

?>
<?php if($_GET['action'] != ''){} else{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=upload">Upload</a>';
} ?>

I hope it works,
Calum

Edited by 84hd0ns: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.