0
votes

If I upload a file to my website via Ajax, and I have the path of it, is there a way I could submit this path to a Django form's built-in FileField?

1
Do you actually need to submit it with form or save it into a model? In second case obj.file.save(filename, File(open(path))) works great. - ilvar
@ilvar thank you for the info. I actually need to submit it with the form, but the info you provided is also useful for the future. Any thoughts on how I could do it with the form? - zallarak

1 Answers

1
votes

I think you can construct a UploadedFile instance from file-like object, put it into dict {'name': temporary_uploaded_file} and provide it to form's files argument. Haven't tried it myself but should be working.