Jump to content

[SOLVED] problem with mkdir path


grandman

Recommended Posts

Hello,

 

Have small script:

 

<?php 

ob_start();

$dirname = $_POST["username"];   

$filename = "/onwards/control/{$dirname}/";   

if (file_exists($filename)) {   

header ( "Location: " . "$filename" . $_POST["username"]);

} else {   

mkdir("{$filename},{$dirname}", 0777);   

echo "welcome " . $_POST["username"] . "Your Area Is Being created.";   

ob_end_flush();

?>   

 

 

This runs when a members logs-in. When run I get this error:

 

Warning: mkdir() [function.mkdir]: No such file or directory in /home/vars/public_html/main/se/pass/pat/join/script.php on line 8

welcome Your Area Is Being created.

 

I think it's trying to create the directory in the folder were the script is. I need it to move two folders further on. Can anyone tell me how I should go about getting the script to move those two folders?

 

I've tied full server path, the path from the script folder and the path including the script folder. None of the aforementioned have worked. The folder I want it to write to, has full write permissions.

 

DG

Link to comment
https://forums.phpfreaks.com/topic/135424-solved-problem-with-mkdir-path/
Share on other sites

Depends, what is your root directory?  Windows or Linux.

 

If your folder is located /home/vars/public_html/main/se/pass/ here and if your script is located here /home/vars/public_html/main/se/pass/pat/join/

 

you would need to do $filename = "../../onwards/control/{$dirname}/";

 

to access another directory up use "../" and you get the point I hope.

 

I do warn you that you might need to validate that their inserting a directory name only allow alphanumeric characters.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.