So I was trying to learn how to do file uploads in Phoenix and I was googling how to do it. Everything points to this page (https://phoenixframework.org/docs/file-uploads) but it’s not there anymore. Which is fine for me since I can use archive.org but does anyone know where the file upload documentation actually is? It’s been pretty hard trying to figure out how to upload files without the documentation.
def upload_route(conn, params) do # multipart/form-data - <input type="file" name="media"> # don't forget the csrf if upload = params["media"] do # upload.path is a real file, and will be removed after request finish # do File.cp before conn call File.cp(upload.path, upload.filename) # your phoenix project dir end end
yeah, just like that
There is a post about File Uploads in Phoenix website under Blog/Guides, which may help you.
You may also want to consider looking at the Arc package especially if you are planning to upload images. I threw together a simple sample of using it which I blogged about here; which might be helpful.
There’s a lot of ways to do uploads.Try also looking at:
The official blog seems to be redesigned…
And when I’m googling “phoenix file upload” that page appears first (but still broken):
And I didn’t think it was broken since a year