Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-08-2005, 04:38 PM New Folder[Resolved]
NineSpoons's Avatar
Junior Talker

Posts: 4
Trades: 0
Hi everybody,
I have a PHP question. I was wondering if there is any way that I can add some PHP code to my site to make it so that whenever a user registers for my site if will create a NEW folder and (if this part is not possible thats OK) copy files into that folder.

I am pretty sure that the first part is possible - but not quite so sure that the second part is. Any help would be greatful.

Thanks in advance,
NineSpoons

Last edited by NineSpoons; 03-09-2005 at 08:32 PM.. Reason: To let know taht this has been resolved (in title)
NineSpoons is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-08-2005, 06:49 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You can use the exec() function to run shell commands, so under unix you can say exec("mkdir $newdirname"); and exec("mv *.* $newdirname");
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 03-09-2005, 02:58 PM
NineSpoons's Avatar
Junior Talker

Posts: 4
Trades: 0
So you're saying this will only work under Unix? Because I have a windows server.
NineSpoons is offline
Reply With Quote
View Public Profile
 
Old 03-09-2005, 03:12 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Try using FTP. I know it's not exactly what your looking for but I think it's the only plausible solution. You can use php's built in ftp functions to log in, navigate to the proper directory and create a new directory and upload the files.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 03-09-2005, 03:13 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
It will work on windows - you just have to replace the arguments you give the function with windows command line stuff.

EDIT:

cptwinky posted while I was writing.

It depends whether the files are being uploaded or just copied/moved from somewhere on the server.
If they are being uploaded for each user then cptwinky's ftp idea is your best bet.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)

Last edited by 0beron; 03-09-2005 at 03:16 PM..
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 03-09-2005, 03:21 PM
NineSpoons's Avatar
Junior Talker

Posts: 4
Trades: 0
Let me rephrase, I will have a file (index.php) in some directotry, I would like PHP to make a new folder (in the same directory) and copy that index.php to that new folder....not sure if that help...
NineSpoons is offline
Reply With Quote
View Public Profile
 
Old 03-09-2005, 03:39 PM
Super Talker

Posts: 110
Trades: 1
You mean you want php to create a directory?

http://uk.php.net/mkdir

Code:
<?php
mkdir("newfolder", 0777);
?>
and then copy the file?

Code:
<?php
$file = 'index.php';
$newfile = 'newfolder/index.php';

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

Last edited by Frank Rizzo; 03-09-2005 at 03:44 PM..
Frank Rizzo is offline
Reply With Quote
View Public Profile Visit Frank Rizzo's homepage!
 
Old 03-09-2005, 04:11 PM
NineSpoons's Avatar
Junior Talker

Posts: 4
Trades: 0
Thank you guys a ton. I am just having one problem - the Directory thing IS working, but then I do:

PHP Code:
 $newdirname2 $name."/upload/";
exec("mkdir $newdirname2"); 
AFTER I do :

PHP Code:
 $newdirname $name;
exec("mkdir $newdirname"); 
(That Code works, but the first one does not)

And it is not working, anybody have any idea why?

And thanks a ton, again, for helping me.

Resolved, thaks again everybody. ( I just used another function.. )

Last edited by NineSpoons; 03-09-2005 at 08:32 PM..
NineSpoons is offline
Reply With Quote
View Public Profile
 
Old 03-10-2005, 09:47 AM
dan245's Avatar
Skilled Talker

Posts: 59
Location: Massachusetts, USA
Trades: 0
try this...

PHP Code:

$username 
$_POST['username'];

$loc "/upload/$username";

mkdir $loc ); 
dan245 is offline
Reply With Quote
View Public Profile
 
Old 03-10-2005, 11:11 AM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
The code you need is:

Code:
$newdirname = $name;
$newdirname2 = "upload";
mkdir ($newdirname, 0777); 
mkdir ("$newdirname/$newdirname2/", 0777)
Regards,

Steve.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Old 05-24-2005, 03:01 PM same problem (almost)
mattsmo's Avatar
Junior Talker

Posts: 1
Trades: 0
here is a script that uses "mkdir()" to make a directory called "$dirname":

PHP Code:
$newdir $_REQUEST['dirname'];
if (
$dirname!=null) {
 if (!
is_dir($newdir)) {
  if (
mkdir($newdir0777)) {
   echo 
"Directory <b>$newdir</b> succesfully created!\n";
  }
 }

i have an advanced file manager script also written in PHP, this file manager recognizes the new directory as a file, this is a trimmed version of the script:

PHP Code:
if ($handle opendir($home."/".$dir)) {
 while (
false !== ($file readdir($handle))) {
  if (
$file != '..' && $file != '.') {
   if (
is_dir($file)) {
    
// $file is a directory
   
}
   else {
    if(@
substr ($file, - @strlen (".html")) === ".html") {
     
// $file is an html file
    
}
    else {
     
// $file is something else
    
}
   }
  }
 }
 
closedir($handle); 

can someone tell me how to make the filemanager recognize the new folder as a directory and not a FILE!

thanks!!!
mattsmo is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to New Folder
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33012 seconds with 12 queries