Current location: Hot Scripts Forums » Programming Languages » PHP » How do i create a folder using php?

How do i create a folder using php?

Reply
  #1 (permalink)  
Old
Newbie Coder
 
Join Date: Oct 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
How do i create a folder using php?

This is a fairly strait forward question. How do i create a folder inside another folder using php? Thanks in advance.
__________________
One may say "They're losing their marbles." I would ask, "Who gave them the marbles in the first place?"
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
Junior Code Guru
 
Join Date: Sep 2004
Posts: 458
Thanks: 0
Thanked 0 Times in 0 Posts
Use the mkdir function to make a new folder
Reply With Quote
  #3 (permalink)  
Old
New Member
 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sabu yes you are right but I tryed this but it did not make any changes and this is my script

Quote:
<form action="" method="post" >
<table width="400" border="0" cellspacing="0" cellpadding="5">
<tr>
<td colspan="3" align="center">Please write gallery name and description</td>
</tr>
<tr>
<td>Name </td>
<td>&nbsp;</td>
<td><input type="text" name="gname" id="text" value=""></td>
</tr>
<tr>
<td>Description</td>
<td>&nbsp;</td>
<td><textarea name="gdescription" cols="30" rows="5" id="textarea"></textarea></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" id="submit" value="Submit"></td>
</tr>
</table>
</form>



<?php


if (isset($submit)) {

mkdir("/gallery/", 0700);

}


?>
please tell me what is wrong??
Reply With Quote
  #4 (permalink)  
Old
New Member
 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
I am sorry about this but this is the right code

Code:
<form action="" method="post" >
<table width="400" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td colspan="3" align="center">Please write gallery name and description</td>
  </tr>
  <tr>
    <td>Name </td>
    <td>&nbsp;</td>
    <td><input type="text" name="gname" id="text" value=""></td>
  </tr>
  <tr>
    <td>Description</td>
    <td>&nbsp;</td>
    <td><textarea name="gdescription" cols="30" rows="5" id="textarea"></textarea></td>
  </tr>
  <tr>
    <td colspan="3" align="center"><input type="submit" name="submit" id="submit" value="Submit"></td>
  </tr>
</table>
</form>



<?php

	
	
	if (isset($_POST['submit'])) {
		
		$name = $_POST['gname'];
		$description = $_POST['gdescription'];
		
		mkdir ("/gallery/$name", 0700);
		
	}


?>
so I want to make the user make his own folder and give it a name from the gname
Reply With Quote
  #5 (permalink)  
Old
Yeroon's Avatar
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 24 Times in 23 Posts
What you typed should work. Are you sure the php script has rights to create new folders in the Gallery folder? I would check that first.
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Reply With Quote
  #6 (permalink)  
Old
New Member
 
Join Date: Aug 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mkdir

hi, try this instead.it should work

mkdir(" name",'0777');
Reply With Quote
  #7 (permalink)  
Old
Nico's Avatar
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,129
Thanks: 12
Thanked 93 Times in 89 Posts
Make sure the parent folder has writing permissions as well.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can create PHP without install? mhs12grade1992 PHP 5 02-10-05 04:12 AM
trying to create my first simple (?) php script, need guidance HotShotPhoto PHP 1 09-06-04 08:12 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM
edit php in Squirrelmail jrcortrightiii PHP 1 07-10-03 02:08 PM


All times are GMT -5. The time now is 06:49 AM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.