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.
3 Likes
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
4 Likes
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.
2 Likes
There’s a lot of ways to do uploads.Try also looking at:
2 Likes
Hi,
The official blog seems to be redesigned…
And when I’m googling “phoenix file upload” that page appears first (but still broken):
https://www.phoenixframework.org/blog/file-uploads
And I didn’t think it was broken since a year