0

I'm very very new to python. I have a HTML code with POST method to upload a file, then I have python code to receive the file and save it to a FTP server. My python code so far is :

        berkas = request.FILES['file']
        filename = "test_send_file.jpg"
        upload_folder = '/var/www/uploads/target_folder/'
        handle_uploaded_file(join(upload_folder, filename), berkas)

Using those codes I got Permission Denied when uploading the file. I know the missing part is where I have to set FTP server address and it's username & password, but I don't know how to that. So, how to do it ?

Or, is there easier way to solve my "POST upload then save to FTP" problem ? Thank you before.

iiandskater
  • 41
  • 1
  • 4
  • 1
    Essentially you are asking us to implement `handle_uploaded_file` without doing any research by your own. But, new to python is no excuse for not doing research and stackoverflow is no code writing service. Doing [a simple search](https://www.google.com/search?q=python+ftp+store+file) gives enough information on how to do it including a link [to the documentation of the builtin ftplib library](https://docs.python.org/2/library/ftplib.html). – Steffen Ullrich Aug 07 '17 at 05:15
  • This example handles your USERNAME and PASSWORD issue : https://stackoverflow.com/questions/12613797/python-script-uploading-files-via-ftp – mbieren Aug 07 '17 at 08:50

0 Answers0