Files and directories
Hello all,
i am busy with making a website where a user gets a home directory.
1. User needs to register,Withing the registration the the home
directory will be made ( working )
2. When a user logs in a session is made based on user name
( working )
3. He can read his directory and the files that are in there
( working )
The files are not posted into the database.
but now i want to make links of it but then i get an error that the
users home directory has the name resource#5 so i can't make links
from the files
small example:
Registration:
<?php
$email = $_POST['email'];
$username = $_POST['username'];
$password = md5($_POST['password']);
if(isset($_POST['register']))
{
$sql = "insert into profiles (username, password) values ('".
$username."','".$password."','".$homepost."')";
$res = mysql_query($sql) or die(mysql_error());
mkdir('home/'.$email,0777);
header("Location: index.php");
}
?>
Reading directory:
<?php
if ($handle = opendir('home/'.$_SESSION['username'])) {
echo "<br />Directory handle: $handle\n<br />";
echo "Files:\n<br />";
// List all the files
while (false !== ($file = readdir($handle))) {
echo "$file";
}
closedir($handle);
}
?>
|