0
Hello, I created an html file with one and I intend to select an image from a directory and after clicking on Ubmit this image should be saved in another directory. Some help?
That’s what I’ve tried so far...
index.html
<form name="pyform" method="POST" action="upload.py">
<input type="file" name="image" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
upload.py
#!c:/Python34/python
# -*- coding: UTF-8 -*-
print("Content-Type: text/html")
print()
import cgi,cgitb
cgitb.enable()
form = cgi.FieldStorage()
file = form['image'].value
upload_dir = 'C:/wamp/www/upload/' # esse é o diretório onde vou salvar a imagem
f = open(upload_dir + file, 'w')
f.write(file)
f.close()
I noticed that after executing the code, a file with the same name as the image is created, however, with size 0kb and cannot be displayed.
you Managed to miss two Different simple Steps, and have each of These Steps directed in one of the two Answers Bellow.
– jsbueno