Folder Creation Script Problem
Posted: Thu May 10, 2007 9:32 pm
I've got a form that calls a php script to create a folder. These folders are used as albums for a photo gallery. The script that gets called looks like this:
Currently when I run my form I get this:
"Warning: mkdir() [function.mkdir]: File exists in C:\wamp\www\mirrabookahs\admin\gallery\createfolder.php on line 8"
So the script doesn't like the $name variable being in the path, but I need it because thats the name of the folder that gets entered in the form on the previous page.
If i change $path to $path = "C:/wamp/www/mirrabookahs/gallery/albums/My Folder Name"; sure enough "My Folder Name" gets created in the directory, but as soon as I change it to a variable it doesn't work.
Even if i change to I get the same error.
Is there anyway I can put that variable in a way that will actually work? Thanks in advance
Code: Select all
<?php
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$name = $_POST['name'];
$path = "C:/wamp/www/mirrabookahs/gallery/albums/$name";
mkdir($path,0755);
$updateGoTo = "listalbums.php";
}
header(sprintf("Location: %s", $updateGoTo));
?>"Warning: mkdir() [function.mkdir]: File exists in C:\wamp\www\mirrabookahs\admin\gallery\createfolder.php on line 8"
So the script doesn't like the $name variable being in the path, but I need it because thats the name of the folder that gets entered in the form on the previous page.
If i change $path to $path = "C:/wamp/www/mirrabookahs/gallery/albums/My Folder Name"; sure enough "My Folder Name" gets created in the directory, but as soon as I change it to a variable it doesn't work.
Even if i change
Code: Select all
mkdir($path,0755);Code: Select all
mkdir('C:/wamp/www/mirrabookahs/gallery/albums/$name',0755);Is there anyway I can put that variable in a way that will actually work? Thanks in advance