Copy a file in Ruby on Rails
Asked Answered
H

1

6

I would like to copy a file from my computer to another specified path. The file 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.

Hairston answered 12/7, 2011 at 17:59 Comment(0)
W
14

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.

Westnorthwest answered 12/7, 2011 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.