Rails: upload a file OR store a url

后端 未结 2 596
南旧
南旧 2021-01-26 17:22

I\'m developing a form where I want to allow users to either upload a file, or enter a url to an existing file.

The idea is to allow users to attach various \'multimedia

2条回答
  •  逝去的感伤
    2021-01-26 18:05

    What I will probably do is to have a drop down in the file upload form to select if the file is from the disk or from external url.

    By default it will set to "from disk", and if they select external url, you could use some AJAX magic and hide the file upload text box and have a text box to use the external url/script etc..

    in the table, you can keep another two columns,

    1 - external url

    2 - file category (external / uploaded file)

    by that way you can distinguish the files and how they what to display in the view

    HTH

提交回复
热议问题