Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Folder

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I am writing some code to create two folders automatically but it seems to be giving the incorrect ownership (root rather than user) and wrong permissions - they need to be readable and writable. This is the first I've done this sort of thing so I hope someone can help!

Code:
$oldumask = umask(0); 
$ServerPath = getenv("DOCUMENT_ROOT");

$NewUserFolder = mysql_insert_id() . "-" . CCGetParam("FirstName", "") . CCGetParam("LastName", "");
mkdir($ServerPath . "/files/" .  $NewUserFolder, 01755);
mkdir($ServerPath . "/files/" .  $NewUserFolder . "/temp/", 01755);
umask($oldumask);

They are being creating with the proper name and in the proper place though.

Don
contact@pc-homepage.com
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases
 
hmm

by returning the $NewDir you immediately terminate the execution of the function. so the ftp_chmod never gets executed.

try putting the return function after the ftp_chmod line

hth
Justin
 
Yes, I wondered about that. However, I get an error:

Call to undefined function: ftp_chmod()

At least now I know it is trying to execute! Any ideas about the error? Is it some server configuration that the hosting company can change?

Don
contact@pc-homepage.com
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases
 
it's only available in certain installations of php v.5 and above.

i'm not sure that many hosting companies will have upgraded yet - there are some significant differences between v4 and v5 - particularly in variable handling.

I found the following excerpt within the php user manual. you should be able to adapt it, I guess.

if ftp_chmod doesn't work, jusdt try this :
Code:
$ftp_ip="ip_of_my_serv_ftp";
$ftp_login="my_login";
$ftp_pass="my_pass";
$ftp_file="/[URL unfurl="true"]www/motd.txt";[/URL]
$conn_id=ftp_connect($ftp_ip);
$login_result=@ftp_login($conn_id, $ftp_login, $ftp_pass);
<!-- Here's the hack -->
$chmod_cmd="CHMOD 0666 ".$ftp_file;
$chmod=ftp_site($conn_id, $chmod_cmd);
ftp_quit($conn_id);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top