Getting a dynamically created folder name using mkdir() in PHP

那年仲夏 提交于 2019-12-12 03:45:28

问题


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


回答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



来源:https://stackoverflow.com/questions/15252504/getting-a-dynamically-created-folder-name-using-mkdir-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!