How to upload a file in ruby on rails?

后端 未结 4 2063
有刺的猬
有刺的猬 2021-02-01 06:16

I’m very new in ruby on rails. I’m stuck with a problem. I want to make a file upload functionality through which I can upload any kind of file (text,image etc.). My controller

4条回答
  •  无人及你
    2021-02-01 06:25

    use "wb" instead of "wp". it works

    File.open(path, "wb") { |f| f.write(upload['datafile'].read)}
    

提交回复
热议问题