0

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

Edited by Sorcher: n/a

3
Contributors
6
Replies
11
Views
6 Years
Discussion Span
Last Post by lordspace
0

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

0

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

0
// 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.

0

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);

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.