gpt4 book ai didi

grails - 如何在Grails中将文件上传到FTP服务器

转载 作者:行者123 更新时间:2023-12-02 15:52:59 25 4
gpt4 key购买 nike

我已经阅读了这里提出的问题的答案:
How to upload file to remote FTP Server in grails

一切都会编译并运行而没有错误。现在如何从Grails表单引用上传服务?对不起这个基本问题。

到目前为止,我正在玩

          <g:form action="do_something" enctype="multipart/form-data" useToken="true">

<span class="button">
<input type="file" name="thefile"/>
<input type="submit" class="upload" value="upload"/>

</span>

</g:form>

但是我只需要一些有关如何将此与服务(可能是通过 Controller )链接的指针。

最佳答案

处理请求。获取文件名并创建一个新文件。我自己的代码:

def f = request.getFile('myfile'); 
def webrootDir = servletContext.getRealPath("/"); //app directory
File fileDest = new File(webrootDir,"xmls/");
def xmlFile = new File(fileDest, "settings.xml");
f.transferTo(xmlFile);

只需 at this post了解更多信息。

关于grails - 如何在Grails中将文件上传到FTP服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36618411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com