2

我在编写 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>
4

2 回答 2

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>

于 2013-10-11T19:24:52.123 回答
1

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

于 2013-10-11T18:50:00.023 回答