开发者

CFFILE attribution error with action="rename", says the file is invalid

开发者 https://www.devze.com 2023-01-28 07:30 出处:网络
My page has a form on it that interacts with a CFC via an ajax post. When the user changes the text and clicks save it should update the DB, which it does, and rename a photo with the value they typed

My page has a form on it that interacts with a CFC via an ajax post. When the user changes the text and clicks save it should update the DB, which it does, and rename a photo with the value they typed in. Everything works except that I keep getting the error:

The value o开发者_开发问答f the attribute source, which is currently /Applications/ColdFusion8/wwwroot/theClient/staging/admin/images/Old_Image.jpg, is invalid.

The file exists and I've changed it to read/write for everyone but ti still gives me the error.

Any ideas?

I should point out that a var in my CFC runs a replace for spaces and changes them out for underscores so, there's no spaces in the filename...


If I remember right this is probably a problem with the destination file name rather then the source filename. I think it's a bug with the error message in CF.


The problem might be that you are using a relative path to the source file. The problem is, relative links in the source attribute are relative to the ColdFusion temporary directory. Try giving an absolute path or using the EXPANDPATH function to create an absolute path to your resource like this:

<cffile action="rename" source="#expandPath('/Applications/ColdFusion8/wwwroot/theClient/staging/admin/images/Old_Image.jpg')#" destination="#expandPath('/Applications/ColdFusion8/wwwroot/theClient/staging/admin/images/NEW_Image.jpg')#">

From the CF 9 documentation on CFFILE action="rename"

If not an absolute path (starting with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function.


I had the same issue and in the end it was something else: the ColdFusion user had no "modify" permission in the folder. It had read/write but not modify. (sigh!)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号