What’s on Line 14 of activate.php?
Oh sorry, it’s:
<?php mkdir("/upload/" . $user_info->user_login); ?>
Should have specified that was line 14
Ah sorry, should have guessed myself.
Would it be a case of that /upload/ is the absolute path rather than the relative path?
And you’re trying to create a folder outside your designated area on a shared server?
Could you look at something like wp_upload_dir()?
http://codex.wordpress.org/Function_Reference/wp_upload_dir
Heh, it was only when you posted that I realized I could change the upload directory rather than set up another FTP account to get decent looking links. Anyways I changed the code to:
<?php $upload_dir = wp_upload_dir(); ?>
<?php mkdir($upload_dir . "" . $user_info->user_login); ?>
Which doesn’t return an error phew, though neither does it create a directory for that user, I however came to the realization $user_info->user_login should only return a value when a user is logged in so I went on to write:
24 <?php $upload_dir = wp_upload_dir();
25 $dirname = $_POST[$user_info->user_login];
26 $filename = "/$upload_dir/{$dirname}/";
27
28 if (file_exists($filename)) {
29 echo ""; } else {
30 mkdir($upload_dir . "" . $user_info->user_login);
31 }
32 ?>
Then chuck it in the theme header but got this error
Warning: mkdir() [function.mkdir]: File exists in /hermes/bosweb/web096/b966/ipg.pixelsgamenet/wp-content/plugins/buddypress/bp-themes/bp-default/header.php on line 30
Sorry if I’m just being silly.
I’ve refined my code more though still having some dificulity, it should work but for some reason it doesn’t:
<?php
global $current_user;
get_currentuserinfo();
$filename = "http://www.pixelsgame.org/upload/{$current_user->user_login}/";
if (file_exists($filename)) {
echo 'http://www.pixelsgame.org/upload/' . $user_info->user_login . ' supposedly already created'; } else {
echo 'http://www.pixelsgame.org/upload/' . $current_user->user_login . ' supposedly just created';
mkdir("$filename");
}
?>
It echoes “http://www.pixelsgame.org/upload/ashton supposedly just created” when I use it though doesn’t create the directory, any clues?
Hi,
You can’t create a dir via a URL. Mkdir operates at a OS level to create the directory.
From your above errors, your path on your server should be something like
/hermes/bosweb/web096/b966/ipg.pixelsgamenet/wp-content/upload/
Awesome! It’s working perfectly now! Well thanks for all the help 🙂 do you think it’d be useful for me to post the code somewhere it can be used again by others or would I just be clogging things up?
I’d be interested in having a look out of curiosity, so if you pastebin the code, and link it here, at least if someone is ever searching for the same solution they have a starting point.
Thanks,
Harry
Sorry, just ended up a bit busy and forgot about this but basically I was using inline upload and had modified it so that when a user uploaded a file it would go to their own directory (I’m using buddypress for a social networking rig) except I discovered the plugin WP-Filebase which makes this obsolete >_<