我使用cfDocument创建了一个pdf,我试图使用fileUpload将它上传到我的服务器,但是它给出了错误:ByteArray objects cannot be converted to strings.
这是我的代码:
// Create PDF
formPdf = "";
cfDocument(format="PDF", name="formPdf") { writeOutput(formContent); };
// Upload the PDF
destination = expandPath("./MyFolder/#ID#/");
if(!directoryExists(destination)){
directoryCreate(destination);
}
fileUpload( destination, formPdf, "*.", "MakeUnique" );fileUpload()只是处理字符串吗?如何上传我刚刚创建的PDF文件?
谢谢
发布于 2019-02-22 20:10:43
对于您的要求,没有必要上传一个文件,因为它已经在您的服务器上,而且cfdocument可以处理生成和保存一个PDF文件。
有关https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-d-e/cfdocument.html的更多信息,请参考cfdocument。cfdocument是设计用来创建一个PDF格式的输入。
您需要filename属性cfdocument。这定义了包含输出的文件的路径名。
你会想要这样的:
destination = expandPath("./MyFolder/#ID#/");
if(!directoryExists(destination)){
directoryCreate(destination);
}
pdfName = "calculatedPDFName.pdf" ;
// Create PDF
cfdocument(format="PDF", filename="#destination#/#pdfName#") {
writeOutput( sanitizeMe(formContent) ) ;
};我将sanitizeMe()作为提醒,提醒您在使用任何表单输入或将其备份之前,特别是在将其保存回文件系统之前清除它。这没什么用,但是应该有一些东西。关于如何以及为什么要这样做,人们围绕着互联网进行了无数次讨论。
注意:我打算链接几个关于XSS和其他注入问题的页面,而出现的第一个链接就是其中之一。https://stackoverflow.com/questions/45597947/in-coldfusion-how-to-eliminate-vulnerable-for-cross-site-script当我低头看答案的时候,我意识到这是我去年的一个。当这一切发生的时候一定要去爱。:-)
https://stackoverflow.com/questions/54833196
复制相似问题