我有一个将图像发送到服务器的Ionic应用程序,用于处理文件上载的脚本是用ColdFusion编写的,由其他人编写,我不是ColdFusion开发人员。以下是他写的内容:
<cfcomponent rest="true" restpath="/app">
<cffunction name="testpostpics" access="remote" returntype="any" produces="application/json" httpmethod="POST" restpath="/testpics">
<cfargument name="file" required="false" type="any" restArgSource="form" />
<cfset var aStruct = {}>
<cfset var pics="https://www.example.com/members/pics/">
<cftry>
<cffile action="upload" filefield="file" nameconflict="makeunique" destination="#picpath#" result="result">
<cfcatch type="any">
<cfset var aStruct = { success = 0, error = "#cfcatch.message#", details = "#cfcatch.Detail#" }>
</cfcatch>
</cftry>``
<cfif StructIsEmpty(aStruct)>
<cfset var aStruct = { success = 1, pic = "#pics##result.ServerFile#" }>
</cfif>
<cfreturn serializeJSON(aStruct)>
</cffunction>
</cfcomponent>
当我尝试上传图片时,响应为空,它不会抛出错误,它只是空的。这是一个示例回复
{"bytesSent":15703,"responseCode":204,"response":"","objectId":""}
我的离子代码:
let options = {
fileKey: "file",
mimeType: "multipart/form-data"
};
fileTransfer.upload(imageFile,'url', options, true).then(resp => {
console.log("resp"+ JSON.stringify(resp));
})
.catch(err => {
console.log("RespError" + JSON.stringify(err));
})
这适用于PHP脚本,但不适用于ColdFusion。 ColdFusion代码有什么问题吗?