Jump to content

simple add folder


nielcleo

Recommended Posts

i just wondering if it is possible in php to create a folder in a specific path.for examplei click the button create folder after i click it it required to put a folder name i put it for example folder1..and path should root/myfolders/folder1if i create a new folder again the path is root/myfolders/folder2.should it be possible in php??

Link to comment
Share on other sites

In most languages related to Unix in any way, the correct command is usually mkdir.Be sure to sanitize incoming data, or a malicious user may do all kinds of nasty things to your system.You mentioned the button click. Are you also unsure how how to get the correct data from the browser to the server?

Link to comment
Share on other sites

The directory name can be anything you want. If you are getting the name from your user, you probably want to allow only certain characters, like letters, numbers, and the _ character. That usually means validating the name with a function that uses regular expressions, like preg_match.The other part of the question is the path to your directory. If your command looks like this: mkdir("something") then the directory will be created in the same directory as your PHP script. If you want the directory to be somewhere else, you will have to pass mkdir a longer path. That means knowing how your server's file system works and how you want your files and directories to be organized.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...