Hello!
I am trying to make this work.

//make user folder
		$userid = $_SESSION['loginid'];
		$userdir = "./u/".$userid."/";
		if (!is_dir($userdir))
		{
		mkdir($userdir,0777);
		copy("/home/users/web/b681/ipg.xxxx/shack/u/index.php","/home/users/web/b681/ipg.xxxx/shack/u/".$userid."/index.php");
		echo "Your directory was created. This is where all your files will be stored.<br>";
		}
		
		else echo "";

This part of the code is Ok but it does not copy the file over to the created folder.
Anyone would like to help me on this?

Trying to copy the /u/index.php to /u/$userdir/index.php

Sincerely,
Sorcher

Read the first comment on this page.

That code is pretty damn stupid. Not even showing the $file vars.

What do you mean ? The reason I pointed to it, is because it mentioned that copy() can be disabled by your host.

// Check if a file has been uploaded
if(isset($_FILES['uploaded_file'])) {
    // Make sure the file was sent without errors
    if($_FILES['uploaded_file']['error'] == 0) {
        // Connect to the database
        $dbLink = new mysqli('xxxx.ipagemysql.com', 'xxxx', 'xxxxx', 'xxxxxx');
        if(mysqli_connect_errno()) {
            die("MySQL connection failed: ". mysqli_connect_error());
        }
///////////////////MAKE USER FOLDER/////////////////////
		$userid = $_SESSION['loginid'];
		$userdir = "./u/".$userid."/";
		$indexx = "./u/".$userid."/index.php";
		if (!is_dir($userdir))
		{
		mkdir($userdir,0777);
////////////////////////COPY FILE///////////////////////
	$file1 = "/home/users/web/b681/ipg.xxxx/shack/u/index.php";
	$file2 = "/home/users/web/b681/ipg.xxxx/shack/u/".$userid."/index.php";
    function copyemz($file1,$file2){ 
          $contentx =@file_get_contents($file1); 
                   $openedfile = fopen($file2, "w"); 
                   fwrite($openedfile, $contentx); 
                   fclose($openedfile); 
                    if ($contentx === FALSE) { 
                    $status=false; 
                    }else $status=true; 
                    
                    return $status; 
    } 
///////////////////////////////////////////////////////////////////////////////////
		echo "Your directory was created. This is where all your files will be stored.<br>";
		}
		
		else echo "";

I tried this.. i dont really understant it :/
And i checked and the copyemz and copy() is enabled on my host.

If you try to copy to files with a relative path, does that work ?

if you have php 5 you could use mkdir with the 3rd parameter so it can create the subdirectories if necessary.

mkdir($userdir,0777, 1);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.