嗯……奇怪的问题……
我正在制作一个表格来上传教学大纲。基本上,有人去搜索一门课程,然后选择课程旁边的“上传教学大纲”按钮。接下来,将弹出一个窗口,提示他们输入文件。我传递此页面信息以将 URL 插入数据库等。
<input name="upload" type="button" value = "Upload Syllabi" id = "uploads" onclick = "window.open('upload_syllabi.cfm?course=#course#&semest=#semester#&ref=#refnum#','popup','width=350,height=170,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0')"/>
它被传递到这个页面:
<cfset session.semester = #url.semest#>
<cfset session.course = #url.course#>
<cfset session.ref = #url.ref#>
<form name = "uploadForm" enctype = "multipart/form-data" action = "upload_action.cfm">
<table align="center" class = "contenttable">
<tr>
<td><h3>Upload Syllabi for <cfoutput><b>#session.semester# #session.course# #session.ref#</b></cfoutput></h3> </td>
</tr>
<tr>
<td align="center">
<input name="syllabiUpload" id = "uploader" type="file" />
</td>
</tr>
<tr>
<td align="center">
<input type="submit" name="uploaded" id="uploaded" value="Upload" />
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center"><a href="javascript:window.close();">[close]</a></td>
</tr>
</table>
</form>
我最初没有会话变量……但我遇到了一些 url.semest 问题……最后我把它们留在那里。
无论如何...提交表单后,它应该转到此页面:upload_action.cfm
<cffile action="upload" filefield="syllabiUpload" destination="#SyllabiLoc#" nameconflict="makeunique">
<cfset SyllabiURL = "#SyllabiPath##cffile.serverfile#">
<cfquery name="checkSyllabi" datasource="#sacsds#" username="#sacsuser#" password="#sacsuser#">
SELECT *
FROM faculty.dbo.Syllabi
WHERE faculty.dbo.syllabi.Semester = '#session.semester#'
AND faculty.dbo.syllabi.Refnum = '#session.ref#'
</cfquery>
<cfif getSyllabi.recordCount is 0>
<cfelse>
<cffile action="delete" file = "#checkSyllabi.url#">
</cfif>
<cfquery name="updateSyllabi" datasource="#sacsds#" username="#sacsuser#" password="#sacsuser#">
UPDATE faculty.dbo.Syllabi
SET url = '#SyllabiURL#'
WHERE Semester = '#session.semester#'
AND Refnum = '#session.ref#'
</cfquery>
<table align="center">
<tr>
<td> </td>
</tr>
<tr>
<td>Uploaded</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
单击提交按钮时出现此错误:
无效的内容类型:''。cffile action="upload" 要求表单使用 enctype="multipart/form-data"。
有点奇怪......因为我的表单中肯定有那行代码......
嗯……
编辑:继续问题#2。
收到此错误:
文件 D:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\ http://uwf.edu/acad/Syllabi/Introduction to Maritime Studies Syllabus2.rtf 中指定的操作删除不存在。
我做cffile删除错了吗?:\ 没有把握..