Coldfusion在网络驱动器上创建目录

时间:2013-10-11 18:28:42

标签: coldfusion coldfusion-10

我在编写ColdFusion 10代码时遇到问题。它只是一个基本的创建网络驱动器上的目录文件夹。该页面有一个文本框,你点击名称点击下一步,然后你去了,但由于某种原因我无法在网上找到类似的东西。

 <cfparam name="selectedDirectory" default="" />
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE>Project Directory Wizard</TITLE>
</HEAD>
<BODY>

<cfinclude template="header.cfm" />
<cfinclude template="mainarea.cfm" />

<cfset VARIABLES.directoryPath = '\\Volz\C$\test' />
<cfset VARIABLES.newDirName = 'bob' />

<form action="results.cfm" method="post">
<input type="text" name="newDirName" />
    <button type="submit">Add Directory</button>
</form>

<cfif cgi.request_method EQ "post">
    <cfif directoryExists(VARIABLES.directoryPath & '\' & form.newDirName )>
         The directory already exists.
    <cfelse>
        <cfset directoryCreate(VARIABLES.directoryPath & '\' & form.newDirName)> 
        The directory didn't exist, but it does now!"
    </cfif>
</cfif>
</BODY>
</HTML>

2 个答案:

答案 0 :(得分:3)

您的表单应如下所示:

<form action="results.cfm" method="post">
    <input type="text" name="newDirName" />
    <button type="submit">Add Directory</button>
</form>

然后您的表单处理程序将具有:

<cfif cgi.request_method EQ "post">
    <cfif directoryExists(VARIABLES.directoryPath & '\' & form.newDirName )>
         The directory already exists.
    <cfelse>
        <cfset directoryCreate(VARIABLES.directoryPath & '\' & form.newDirName)> 
        The directory didn't exist, but it does now!"
    </cfif>
</cfif>

请注意,没有理由使用<cfdump>

答案 1 :(得分:1)

要访问联网驱动器,您需要以具有该共享权限的用户身份运行ColdFusion。检查您的CF服务设置。