在ColdFusion中将文件保存到服务器 [英] Saving file to server in ColdFusion
本文介绍了在ColdFusion中将文件保存到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< p>< p> ; cfform name =uploadImgFormmethod =postaction =#CGI.PATH_INFO#?#CGI.QUERY_STRING#enctype =multipart / form-data>
< input name =txtImgtype =file/>
< input name =btnSubmittype =submit/>
< / cfform>
< cfif isDefined(Form.txtImg)>
fileField =txtImg
destination =/ Images
accept =image / jpeg
nameconflict =makeunique >
< / cfif>
我打算做一些验证,但是我想先得到这个简单的例子。 p>
我在后面碰到这个,在上传之前尝试重命名文件时很有帮助:
Adobe链接
必须是一个完整的路径,否则它会被发送到一个相对于ColdFusion临时目录的目录。
试试这个:
< cfset destination = expandPath(Images)/>
fileField =txtImg
destination =#destination#
accept =image / jpeg
nameconflict =makeunique>
After doing some research I feel this should work, however it is not saving the file to my Images directory.
<cfform name="uploadImgForm" method="post" action="#CGI.PATH_INFO#?#CGI.QUERY_STRING#" enctype="multipart/form-data">
<input name="txtImg" type="file" />
<input name="btnSubmit" type="submit" />
</cfform>
<cfif isDefined("Form.txtImg")>
<cffile action="upload"
fileField = "txtImg"
destination="/Images"
accept="image/jpeg"
nameconflict="makeunique">
</cfif>
I plan on doing some validation, but I would like to get this simple example working first.
I came across this later which is helpful when trying to rename a file before upload: Adobe link
解决方案
The destination has to be a full path, otherwise it gets sent to a directory relative to the temp directory of ColdFusion.
Try this:
<cfset destination = expandPath("Images") />
<cffile action="upload"
fileField = "txtImg"
destination="#destination#"
accept="image/jpeg"
nameconflict="makeunique">
这篇关于在ColdFusion中将文件保存到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文