Hmmm...strange problems...
I'm making a form to upload syllabi. Basically, someone go search for a course and select the button next to the course that says "Upload Syllabi." Next, a window will popup prompting them for the file. I pass this page info to insert the URL into the database etc.
<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')"/>
It is passed to this page:
<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>
I had originally had no session variables...but I was having some problems with url.semest...and I had just ended up leaving them there.
Anyway...when the form is submitted it should go to this page: 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>
I get this error when I click the submit button:
Invalid content type: ''. The cffile action="upload" requires forms to use enctype="multipart/form-data".
Kind of weird...cause I definitely have that line of code in my f开发者_JS百科orm...
hm....
EDIT: Continue Problem # 2.
Getting this error:
File D:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\http://uwf.edu/acad/Syllabi/Introduction to Maritime Studies Syllabus2.rtf specified in action delete does not exist.
Did i do the cffile delete wrong? :\ Not sure..
could be a browser issue or you have some kind of anti-virus, proxy or firewall messing with the upload. As you say, you are telling the browser to use the right encoding so presumably that is getting lost in translation somewhere.
Option 2 is you are seeing cached pages and not the version with the correct form. Try clearing out your browser cache.
EDIT: Actually the problem is simple. You haven't told it to use method="POST" on the form.
精彩评论