Jump to content
Sign in to follow this  
defiant1970

Mkdir

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/"

Share this post


Link to post
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);

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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);		 		 ?>

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...