AJAX文件上传重装应用程序

时间:2011-11-15 12:52:14

标签: ajax scala file-upload lift

我有以下代码段

class PresentationUpload {

    def uploadForm(form:NodeSeq) : NodeSeq = {

        var fileHolder: Box[FileParamHolder] = Empty

        def handleFile() = {

            fileHolder.map { holder =>

                val filePath = "src/main/webapp/files"
                val oFile = new File(filePath, holder.fileName)

                val output = new FileOutputStream(oFile)
                output.write(holder.file)
                output.close()

            } openOr {

                // Do something

            }


        }

        val bindForm = "type=file" #> fileUpload((fph) => fileHolder = Full(fph)) &
                       "type=submit" #> ajaxSubmit("Submit", handleFile _)

        ajaxForm(bindForm(form))

    }

}

文件上传正确,然后重新加载应用程序,这是处理ajax上传的正确方法还是我应该使用另一种方法?

感谢您的帮助,非常感谢

1 个答案:

答案 0 :(得分:0)

我已经将升降机项目(通常是“project / build / LiftProject.scala”)配置为在更改文件目录后没有重新加载,问题解决了:)

override def scanDirectories = ( 

    temporaryWarPath / "WEB-INF" * ("classes" | "lib") 

).get.toSeq