Skip to content

Instantly share code, notes, and snippets.

@steinbring
Last active January 3, 2016 15:19
Show Gist options
  • Save steinbring/8482307 to your computer and use it in GitHub Desktop.
Save steinbring/8482307 to your computer and use it in GitHub Desktop.
I've been having trouble with cffile on a particular website. I created this as a test of a hypothesis. I think cffile's accept attribute is borked on CF10. I tested it on CentOS/Apache/CF10 Standard and localhosted on Win7. Go to http://steinbring.net for the explanation.
<form method="post" enctype="multipart/form-data">
<input name="theFile" type="file">
<input name="submitButton" name="submit" type="submit" value="Upload">
</form>
<cfif isDefined("form.theFile")>
<!--- Is there a file? Upload it to the files folder. --->
<cffile action="upload"
filefield="theFile"
accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
destination="#expandpath('/mimetype/files')#"
mode="775"
nameconflict="Makeunique"
result="local.UploadedFile">
<cfdump var="#local.UploadedFile#">
</cfif>
<hr>
<!--- What file have you already uploaded? --->
<cfdirectory directory="#expandpath('/mimetype/files')#" name="qryDir" action="LIST" type="file">
<!--- Show them --->
<table>
<tr>
<th colspan="2">Files that are uploaded</th>
</tr>
<tr>
<th>Filename</th><th>Mimetype</th>
</tr>
<cfoutput query="qryDir">
<tr>
<td>#qryDir.name#</td><td>#FilegetMimeType(expandPath(qryDir.name))#</td>
</tr>
</cfoutput>
</table>
<form method="post" enctype="multipart/form-data">
<input name="theFile" type="file">
<input name="submitButton" name="submit" type="submit" value="Upload">
</form>
<cfif isDefined("form.theFile")>
<!--- Is there a file? Upload it to the files folder. --->
<cffile action="upload"
filefield="theFile"
destination="#expandpath('/mimetype/files')#"
mode="775"
nameconflict="Makeunique"
result="local.UploadedFile">
<cfdump var="#local.UploadedFile#">
</cfif>
<hr>
<!--- What file have you already uploaded? --->
<cfdirectory directory="#expandpath('/mimetype/files')#" name="qryDir" action="LIST" type="file">
<!--- Show them --->
<table>
<tr>
<th colspan="2">Files that are uploaded</th>
</tr>
<tr>
<th>Filename</th><th>Mimetype</th>
</tr>
<cfoutput query="qryDir">
<tr>
<td>#qryDir.name#</td><td>#FilegetMimeType(expandPath(qryDir.name))#</td>
</tr>
</cfoutput>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment