Forum Moderators: coopster

Message Too Old, No Replies

Need PHP Version

of this ASP script

         

5x54u

9:47 pm on May 5, 2005 (gmt 0)

10+ Year Member



I am looking for way to do this with PHP.

Basically I need to, when a new cateogry is created in the db it runs a PHP script that checks to see if dir exists and creates it if not.

Here is an ASP example:

<%
Dim objFSO, objFolder
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

objFolder = Trim(Request("FN"))

'Create Folder if it doesn't already exist
If Not objFSO.FolderExists("D:\Websites\#*$!xx\Articles\"& objFolder) then
objFSO.CreateFolder("D:\Websites\#*$!xx\Articles\"& objFolder)
End If
%>

THank you for any help

jusdrum

10:13 pm on May 5, 2005 (gmt 0)

10+ Year Member



I normally don't answer the "I need a script for this!"-type posts, but I wanted to show you how much simpler PHP is.

<?php
$Root = "c:\some\dir\";
$Dir = $_GET['FN'];
$NewDir = $Root . $Dir;
if (!is_dir($NewDir) && is_writable($Root))
{
mkdir($NewDir);
}
?>

jatar_k

10:15 pm on May 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> I normally don't answer the ...

glad you did, I have no idea what that says ;)

5x54u

10:36 pm on May 5, 2005 (gmt 0)

10+ Year Member



thanks guys!

I did not know exactly what PHP function() would do that and being that it is on a IIS box I was not sure.


This APS script came from my ASP is better than anything guy and I can't wait to show him this jusdrum and thank you for taking the time.

Thank you

LOL jatar_k

olwen

10:43 pm on May 5, 2005 (gmt 0)

10+ Year Member



Just wondering if

$Dir = $_GET['FN'];

would be better as

$Dir = $_REQUEST['FN'];