File upload 我可以使用Coldfusions cffile action=";上传“;使用图像目标url?

File upload 我可以使用Coldfusions cffile action=";上传“;使用图像目标url?,file-upload,coldfusion,verification,cffile,File Upload,Coldfusion,Verification,Cffile,在更改文件大小并将其存储到服务器之前,我需要遍历路径名和图像名列表,并验证文件是否存在以及是否为jpg/png 我想用这个: <cffile result="upload" action="upload" accept="image/jpeg, image/png" destination="#tempDirectory#" nameconflict="overwrite" /> <cfset testFilePath = tempDirectory &

在更改文件大小并将其存储到服务器之前,我需要遍历路径名和图像名列表,并验证文件是否存在以及是否为jpg/png

我想用这个:

   <cffile result="upload" action="upload" accept="image/jpeg, image/png" destination="#tempDirectory#" nameconflict="overwrite" />
    <cfset testFilePath = tempDirectory & upload.serverFile>
    <cfimage name="tempFile" action="read" source="#testFilePath#" />
    <cfif NOT isImageFile( testFilePath ) >
        <cfset fileDelete( testFilePath ) />
        <cfthrow type="FileNotFound" message="#tx_settings_icons_error_img#" />
    <cfelseif NOT listfindnocase(allow, upload.serverfileext) >
        <cfset fileDelete( testFilePath ) />
        <cfthrow type="FileNotFound" message="#tx_settings_icons_error_file#" />
    </cfif>
问题

我可以只
读取
图像,执行验证,然后存储到磁盘,还是需要先上传图像。我将不得不循环浏览500个图像的列表,我正在阅读的
cffile action=“read”
不应与大文件一起使用。检查图像文件的正确类型、
isImage
和文件扩展名的替代方法是什么?

使用cfimage从URL读取文件。将源设置为该URL。然后,您可以在本地将其写入磁盘

代码示例:

<cfset imageData = ImageRead("http://tutorial28.learncf.com/img/bgHead.png") />
<cfimage action="write" source="#imageData#" destination="#expandPath('test.png')#" />

我通常使用
cfhttp
读取图像并验证我是否拥有它,然后转换为有效的
cfimage
对象并执行操作。你可以在答案中看到我的过程

<cfset imageData = ImageRead("http://tutorial28.learncf.com/img/bgHead.png") />
<cfimage action="write" source="#imageData#" destination="#expandPath('test.png')#" />