Jump to content

[SOLVED] how to copy a folder and change the name?


Recommended Posts

Basically I've been overcomplicating things.  I've been trying to make a directory and a folder and files at the same time.  when I could've just copied the folder and renamed it.

 

I want the users to submit a form that copys a folder and changes the name to what the user submitted into the form.

 

Is this possible would I use makedir() or copy()?

 

Thanks all help is appreciated!

Okay, I've got a copy code, but it's giving me errors.  Someone please Help?  :-\

 

<?php

$dir = $_POST[dir];

mkdir("/home/wiicharg/public_html/hubchat/$dir", 0755);
chmod("/home/wiicharg/public_html/hubchat/$dir", 0777);  

$file = 'http://wiicharged.com/hubchat/hubex/shout.php';
$newfile = 'http://wiicharged.com/hubchat/$dir/shout.php';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}

$file = 'http://wiicharged.com/hubchat/hubex/shout.swf';
$newfile = 'http://wiicharged.com/hubchat/$dir/shout.swf';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}

$file = 'http://wiicharged.com/hubchat/hubex/shout.txt';
$newfile = 'http://wiicharged.com/hubchat/$dir/shout.txt';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}


?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.