开发者

Copy a file in Ruby on Rails

开发者 https://www.devze.com 2023-03-20 00:38 出处:网络
I would like to copy a file from my computer to another specified path. The file开发者_JAVA技巧 has to be chosen by the user with a file_field and the destination is already hard-coded. How can I do t

I would like to copy a file from my computer to another specified path. The file开发者_JAVA技巧 has to be chosen by the user with a file_field and the destination is already hard-coded. How can I do that ? Thank you.


I'd use FileUtils::cp, but beware of path mangling via ../../<file>. For that, you can use expand_path and then check if the resulting path begin matches your jail.

0

精彩评论

暂无评论...
验证码 换一张
取 消