0

I am dynamically creating folders for each user in my php file with

mkdir("Userfiles/".$company."_".$time_stamp); 

I want to save that directory in a variable or any other and I have to use the directory name for saving my .txt files in it

$myFile = "exfiles/".str_replace(" ","-",$_POST['company'])."_CC Booth furnishings ".$order_type."_".$time_stamp.".txt";

In the place of 'exfiles' I need to give the dynamically created directory name. Any help will be appreciated. Thanks

3
  • 3
    1) You can just save the string you pass into mkdir. 2) You should really be sanitizing user input data before creating a folder using it. Commented Mar 6, 2013 at 16:18
  • @Dogbert Or, really, before doing anything with it besides holding it in a variable. Commented Mar 6, 2013 at 16:21
  • Thanks for advices, I will keep in mind. Commented Mar 6, 2013 at 16:38

1 Answer 1

1
$dirname = "Userfiles/".$company."_".$time_stamp;
mkdir($dirname);
$myFile = $dirname . str_replace(" ","-",$_POST['company'])."_CC Booth furnishings ".$order_type."_".$time_stamp.".txt";

As stated in the comments of your question:

Don't use $_POST data directly to manipulate files on the server. Always sanitize it

Sign up to request clarification or add additional context in comments.

1 Comment

Thank u, quick ans worked like a gem. Thans again for saving my time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.