I have a form with “subject”, “body” and “file” fields on some page on my Django site.
If “subject” and/or “body” parameters exist in GET, I pre-fill them in the form from server side.
I want to do the same with “file” field – more exactly, I want if there is an “URL” parameter in request.GET, take the file from this URL and pre-fill the “file” field with it.
I’ve googled and still have no idea how to implement this whether with pure Javascript or with server-side help, and from my experience, it isn’t possible (or at least hard to do) in most browsers due to input type=”file” nature.
Is it in fact possible to implement it in some way?
You can’t pre-fill a file field. But I don’t think you need to use one at all, since you’re getting the file from a URL, not from the user’s local machine. Just use a normal text field for the URL, and get the file server-side (eg using
urllib) after the form is submitted.