Hi! I have a question about creating directories. I have two things I'm trying to do for two separate projects. First, I'm trying to create a directory based on a users ID. basically so each user has his own directory on the server where things like his profile picture, uploaded pictures and so forth would go. I am currently using fancy upload for this. Here is the relevant code for this process:
$clientdir=$_SERVER['QUERY_STRING'];
$result = array();
if (isset($_FILES['photoupload']) )
{
$file = $_FILES['photoupload']['tmp_name'];
$error = false;
$size = false;
if (!is_uploaded_file($file) || ($_FILES['photoupload']['size'] > 2 * 1024 * 1024) )
{
$error = 'Please upload only files smaller than 2Mb!';
}
elseif (!$error && !($size = @getimagesize($file) ) )
{
$error = 'Please upload only images, no other files are supported.';
}
elseif (!$error && !in_array($size[2], array(1, 2, 3, 7, 8) ) )
{
$error = 'Please upload only images of type JPEG.';
}
elseif (!$error && ($size[0] < 25) || ($size[1] < 25))
{
$error = 'Please upload an image bigger than 25px.';
}
else {
move_uploaded_file($_FILES['photoupload']['tmp_name'], "$clientdir".$_FILES['photoupload']['name']);
chmod("$clientdir".$_FILES['photoupload']['name'], 0777);
}
This is obviously quite broken, but basically what I'm trying to do here is that when a user creates an account a directory is created based on their user id. (I have this working) but I need the upload script to recognize that user "a" is logged in and files should be moved to his directory from the temp directory.
Second project is that I'm trying to create a photo gallery that can have multiple albums. Basically the user has a form that asks them if they'd like to upload pictures to a new album (they then enter the name of the album) or a currently existing album. and then any photos they upload are then uploaded to that directory. or database? My question here is, should I have the files go to a database or directory, and how would I need to implement the new album feature. I'm guessing just have it create a new directory when a "new album" is chosen, but again, my problem is getting files moved from "temp" to whats basically a $_post variable...
I don't necessarily need a bunch of code posted, I'm fairly proficient, just an idea of what I'm doing wrong and need to do.
Hope that makes sense...
Thanks very much!
Michael