Jump to content

Mkdir


defiant1970
 Share

Recommended Posts

Hello again I am tring to make a directory from my page and I have tried a few different ways without any luck.Here is my code I hope someone can make heads or tails out of it <form enctype="multipart/form-data" method="post"> <input type="text" name="FileName" /> <input type="submit" value="CreateFile" /> </form> <?php $target_path = "farm/$userID/"; $NewFolder = ($_POST["FileName"]); mkdir($target_path/$NewFolder ,2); ?>the $userID is the person who is login and the ID is also the name of there folder in the farm. I have a file listing app ant it works with "farm/$userID/"

Link to comment
Share on other sites

First of all, you should have an action attribute on the form, even if it's empty.This is a mistake:mkdir($target_path/$NewFolder ,2);
Thank you for your replyIf this is a mistake then what am I doing wrong???All the documention I have found it wrote the file right from the function
Link to comment
Share on other sites

When the slash character is not in quotations, PHP will treat is as the division operator. If you want that path to be interpolated as a string, you'll need to put it all in double quotations marks, like you did here: "farm/$userID/" The 2 looks wrong, also. I've never seen mkdir passed anything there but an octal value like 0755Have you looked here? http://www.php.net/manual/en/function.mkdir.php

Edited by Deirdre's Dad
Link to comment
Share on other sites

<form enctype="multipart/form-data" action="" method="post"> <input type="text" name="FileName" /> <input type="submit" value="CreateFile" /> </form> <?php $target_path = "/farm/$userID/"; $NewFolder = ($_POST["FileName"]); mkdir("$target_path" & "/" & "$NewFolder" ,0755); ?>This what I have tried now still no luck

Link to comment
Share on other sites

<?php $target_path = "/farm/$userID/"; $NewFolder = ($_POST["FileName"]); mkdir("$target_path" & "/" & "$NewFolder" ,0755); ?>
try this:
		 <?php 		 $target_path = "/farm/$userID/";		 $NewFolder = $_POST["FileName"];		 mkdir($target_path . $NewFolder ,0755);		 		 ?>

Link to comment
Share on other sites

thank you But there must be something Iam missing I even tried<form enctype="multipart/form-data" action="" method="post"> <input type="text" name="FileName" /> <input type="submit" value="CreateFile" /> </form> <?php $NewFolder = ($_POST["FileName"]); $target_path = "/farm/$userID/$NewFolder"; mkdir($target_path, 0755); ?>the closest I got it to work is add a folder in the admin folder which is where the script is running

Edited by Harry Rorarius
Link to comment
Share on other sites

I see, have you tried with $_SERVER['DOCUMENT_ROOT']?

<?php$target_path = $_SERVER['DOCUMENT_ROOT'] ."/farm/$userID/";$NewFolder = ($_POST["FileName"]);mkdir("$target_path" & "/" & "$NewFolder" ,0755);?>

maybe that's why it doing it's thing in the same directory

Link to comment
Share on other sites

I see, have you tried with $_SERVER['DOCUMENT_ROOT']?
<?php$target_path = $_SERVER['DOCUMENT_ROOT'] ."/farm/$userID/";$NewFolder = ($_POST["FileName"]);mkdir("$target_path" & "/" & "$NewFolder" ,0755);?>

maybe that's why it doing it's thing in the same directory

Thank you very much that was the ticketmakeing this file system browser is a pane in the but
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...