35 lines
651 B
Python
Executable File
35 lines
651 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
import cgi, os
|
|
import cgitb
|
|
|
|
cgitb.enable()
|
|
|
|
form = cgi.FieldStorage()
|
|
|
|
print("Content-type: text/html")
|
|
print("")
|
|
|
|
print('<html>')
|
|
print('<head>')
|
|
print('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">')
|
|
print('<title>File upload</title>')
|
|
print('</head>')
|
|
print('<body>')
|
|
|
|
print("Salut")
|
|
|
|
fileitem = form['filename']
|
|
|
|
|
|
if fileitem.filename:
|
|
print("Uploaded file : "+fileitem.filename)
|
|
filename = os.path.basename(fileitem.filename)
|
|
uploadedfile = open("../uploads/"+filename, 'wb')
|
|
uploadedfile.write(fileitem.file.read())
|
|
else:
|
|
print("No file uploaded")
|
|
|
|
print('</body>')
|
|
print('</html>')
|