0 Replies - 243 Views - Last Post: 27 February 2014 - 10:30 AM Rate Topic: -----

#1 JJ1717  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 05-April 13

Uploading file to a server via ftplib from a html form?

Posted 27 February 2014 - 10:30 AM

Hello everyone,

I have been working on creating a simple ftplib upload script that can send a file to a server. Everything works fine but now I want to know if its possible to use a html form to allow a user to chose the file to be uploaded. This would mean defining the file from the form in the script. I am unsure of how to go about this?

Here is my ftp upload script:
import ftplib

filename = 'test.doc'
ftp = ftplib.FTP('ftp.*******.com')
ftp = ftp.login('****','*****')
ftp.cwd('uploads')
myfile = open('/Users/Joey/Downloads/test.doc', 'rb')
ftp.storbinary('STOR ' + filename, myfile)
ftp.quit



I have been using the Python shell to execute this script, will I need to make changes if I wanted this script to be executed when the user submits the form?

I am using wamp as a local server to host my simple html form on a webpage. I am assuming you need a variable to record the file chosen from the form, instead of my script just having the test file already written?

Thanks for any help in advance

Is This A Good Question/Topic? 0
  • +

Page 1 of 1