简体   繁体   English

如何使用PHP动态创建文件夹

[英]How to make a folder dynamically with PHP

I want to allow the user to add something, and get a folder: 我想允许用户添加一些东西,并获得一个文件夹:

example.com/foo

But I DONT want the folder to actually be there, I want it to be made instantaneously, so that I can still use the directory foo for private files (If I wanted to). 但是我不希望该文件夹实际存在,我希望它是即时创建的,因此我仍然可以将目录foo用于私有文件(如果需要)。

The name of the folder will be stored in a mySQL database, so all that remains is to map it. 该文件夹的名称将存储在mySQL数据库中,因此剩下的就是对其进行映射。 But how? 但是如何?

Maybe this is what you're looking for. 也许这就是您要寻找的。 Instead of doing example.com/foo , use example.com/something/foo . 代替example.com/foo ,使用example.com/something/foo Then use an .htaccess rewrite rule: 然后使用.htaccess重写规则:

RewriteEngine on
RewriteRule ^/?something/(\w+)$ fake.php?file=$1

Then you could have fake.php do everything that you need it to. 然后,您可以让fake.php做您需要做的所有事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM