小编Jac*_*ack的帖子

Chrome的Cookie过期日期出错

我在Chrome上的Cookie过期日期有问题.我使用ColdFusion设置了两个这样的cookie:

<cfset thekey = generatesecretkey("DESEDE")>
<cfcookie name="cookie1" value="#Hash(userid&thekey,'SHA-256')#" httponly="true" >
<cfcookie name="cookie2" value="#thekey#" httponly="true" >
Run Code Online (Sandbox Code Playgroud)

他们已经工作了一段时间.但是,在升级到ColdFusion 10并使用Chrome之后,奇怪的事情开始发生了.它只发生在Chrome浏览器上.其他浏览器没有此问题:

当设置这两个cookie时,它们的最终有效期为1969年12月31星期三下午7:00:11

这让我很困惑.你没看到,我没有设定任何到期日.所以默认只是会话.它们应该在用户会话结束时到期.我的问题是这个日期来自哪里?它来自ColdFusion 10服务器还是Chrome?我很遗憾为什么这个日期会出现在Chrome 的Cookie的Expires字段中.在此到期日期,cookie已被视为已过期且无效.

cookies coldfusion google-chrome coldfusion-10

16
推荐指数
1
解决办法
1万
查看次数

使用 Coldfusion 从 web url 上传文件

我一直允许用户通过在线表单上传文件,如下所示:

<form action="upload.htm" enctype="multipart/form-data" name="upload_form" method="post">
<input type="file" name="upfile">
<input type="submit" name="upload" value="Upload Photos">
</form>
Run Code Online (Sandbox Code Playgroud)

然后在后端,cffile 将上传文件:

<cffile action="upload" destination="#currentpath#" accept="image/jpeg, image/gif, image/png" fileField="form.upfile" nameconflict="makeunique">
Run Code Online (Sandbox Code Playgroud)

现在我想做自动化,以便图像文件不必位于用户的计算机中,而是来自网络目的地,例如http://www.sample.com/images/myimage.jpg而不是 c:/images/我的图片.jpg

我试过这个:

<cfhttp method="get" url="http://www.example.com/images/myimage.jpg"  resolveurl="Yes" throwOnError="Yes">
<cfif cfhttp.mimeType eq "image/jpeg">
    <cfset currentpath = expandpath('/test/')>
    <cffile action="upload" destination="#currentpath#" accept="image/jpeg, image/gif, image/png" fileField="#cfhttp.fileContent#" nameconflict="makeunique">
</cfif>
Run Code Online (Sandbox Code Playgroud)

但是,它给了我一个错误:

无效的内容类型:''。文件上传操作需要表单使用 enctype="multipart/form-data"

我没有使用表单上传,但它似乎需要一个表单字段。

所以我试过这个:

<cfhttp method="get" url="http://www.example.com/images/myimage.jpg"  resolveurl="Yes" throwOnError="Yes">
<cfif cfhttp.mimeType eq "image/jpeg">
    <cfset currentpath = expandpath('/test/')>
    <cffile action="write" output="#cfhttp.fileContent#"  file="#currentpath#/someimage.jpg">
</cfif>
Run Code Online (Sandbox Code Playgroud)

这个写出一个名为 someimage.jpg 的“文件”,但输出不是一个 jpg 文件,而是一些无法识别的文件。使用 …

coldfusion upload cffile cfhttp

4
推荐指数
1
解决办法
1074
查看次数

查询中的Coldfusion MySQL查询

我正在尝试从特定用户检索的完整记录集中检索特定年份和月份的记录.首先,有问题的字段itemdate是MySql类型的Datetime(例如2016-08-15 20:00:25).用户有4行记录:

2016-08-15 20:00:25
2015-06-01 20:25:05
2016-08-15 20:26:00
2016-08-15 23:30:35
Run Code Online (Sandbox Code Playgroud)

通过以下方式检索特定用户的这些记录:

<cfquery datasource="userdatbase"name="reportlist">
select itemid, itemdate, itemvalue
from itemlib
where userid = '#currentuserid#'
</cfquery>
Run Code Online (Sandbox Code Playgroud)

当前年份和月份由以下因素确定:

<cfset thisyear = #Year(Now())#>
<cfset thismonth = #Month(Now())#>
Run Code Online (Sandbox Code Playgroud)

现在过滤原始查询,只获取当前年份和月份的查询:

    <cfquery dbtype="query" name="detail"> 
        select itemid, itemdate, itemvalue
        from reportlist
        where year(itemdate) = #thisyear#
        and month(itemdate) = #thismonth#
    </cfquery>
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

执行数据库查询时出错.

查询查询语法错误. 遇到"年.不正确的条件表达式,期望的[像| | | | | | |比较]条件之一,

我试图这样做:

    <cfquery dbtype="query" name="detail"> 
        select itemid, itemdate, itemvalue
        from reportlist
        where #year(reportlist.itemdate)# = #thisyear#
        and #month(reportlist.itemdate)# = #thismonth# …
Run Code Online (Sandbox Code Playgroud)

mysql coldfusion date cfquery

1
推荐指数
1
解决办法
149
查看次数