defiant1970 Posted February 26, 2010 Share Posted February 26, 2010 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 More sharing options...
Ingolme Posted February 26, 2010 Share Posted February 26, 2010 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); Link to comment Share on other sites More sharing options...
defiant1970 Posted February 26, 2010 Author Share Posted February 26, 2010 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 More sharing options...
jeffman Posted February 27, 2010 Share Posted February 27, 2010 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 Link to comment Share on other sites More sharing options...
defiant1970 Posted February 27, 2010 Author Share Posted February 27, 2010 <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 More sharing options...
Matpatnik Posted February 27, 2010 Share Posted February 27, 2010 <?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 More sharing options...
defiant1970 Posted February 27, 2010 Author Share Posted February 27, 2010 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 Link to comment Share on other sites More sharing options...
Matpatnik Posted February 27, 2010 Share Posted February 27, 2010 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 More sharing options...
defiant1970 Posted February 27, 2010 Author Share Posted February 27, 2010 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 More sharing options...
Matpatnik Posted February 27, 2010 Share Posted February 27, 2010 I'm glad it help Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.