How can I upload some files to my website? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How can I upload some files to my website? (/thread-32927.html) |
How can I upload some files to my website? - brunolelli - Mar-17-2021 Hello guys, I'm currently saving some .csv files on my computer, but I would like to upload those .csv files to my website, is it possible to be done using Python? RE: How can I upload some files to my website? - ndc85430 - Mar-17-2021 How do you normally upload stuff to your site? If you use FTP, for example, Python certainly has an FTP client in the standard library. RE: How can I upload some files to my website? - brunolelli - Mar-17-2021 (Mar-17-2021, 01:24 PM)ndc85430 Wrote: How do you normally upload stuff to your site? If you use FTP, for example, Python certainly has an FTP client in the standard library. Yes, I normally do it using FTP. let me try! RE: How can I upload some files to my website? - snippsat - Mar-17-2021 You can use Requests for this. A couple of examples. import requests response = requests.put('http://ftp://username:[email protected]/backup/') import requests headers = {'Content-Type': 'multipart/form-data',} files = { 'data': ('test.mp3', open('test.mp3', 'rb')), } response = requests.post('http://mysuperserver/media/upload/', headers=headers, files=files) |