php ile yeni bir klasör oluşturun

0 Cevap

I have a file upload script that works [finally] but want to have users submit pics into a folder, which I want to be created as the users name. I was thinking I could just maybe submit the file and then it would jsut create it, but it didn't, so how can I do this? This is my script: PHP Code:

<?php 
// Configuration part  
$dbhost = "localhost"; // Database host  
$dbname = "users"; // Database name  
$dbuser = "dbuser"; // Database username  
$dbpass = ""; // Database password  

// Connect to database  
$db = mysql_connect($dbhost, $dbuser, $dbpass) or die("Error: Couldn't connect to database");  
mysql_select_db($dbname, $db) or die("Error: Couldn't select database.");  

if($IsLoggedIn) 
{ $userid = $_GET["userid"]; 
    if($_POST['Submit']) 
        { 

            if($userid) 
            { $uploadName = mysql_query("SELECT * FROM users WHERE userId ='" 
                             . $userid . "'"); 
            while ($upName = mysql_fetch_row($uploadName)) 
                { $userName2 = $upName[1]; 
                   $userPic1 = $upName[11];  
                   echo "$userName2"; } } 

//If the Submitbutton was pressed do:  

            if ($_FILES['imagefile']['type'] == 'image/pjpeg') 
                {  

//this is where the pic is put into a folder by the username 
    copy ($_FILES['imagefile']['tmp_name'],  
    "pics/profiles/" . $userName2 . "/" . $_FILES['imagefile']['name'])  
    or die ("Could not copy");  

        echo "";  
        echo "Name: ".$_FILES['imagefile']['name']."";  
        echo "Size: ".$_FILES['imagefile']['size']."";  
        echo "Type: ".$_FILES['imagefile']['type']."";  
        echo "Copy Done....";  
        }  


        else {  
            echo "";  
            echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")";  
        }  
}  

?> 
<form name="form1" method="post" action="index.php?page=classupload&userid=<?php echo "$userid"; ?>" enctype="multipart/form-data">  
<input type="file" name="imagefile">  

<input type="submit" name="Submit" value="Submit">  
</form> 
<?php } else { ?>How did you get here? You aren't <a href="index.php?page=login">Logged In</a>. 
<?php } ?>

Bunu yapmak için herhangi bir yolu var mı? Kullanıcı yapıldığında Belki bile? teşekkürler!

0 Cevap