Код: Выделить всё
File:
#!C:/Users/Vitriv-Desktop/AppData/Local/Programs/Python/Python36-32/python.exe
import cgi, os
import cgitb; cgitb.enable()
from PIL import Image
form = cgi.FieldStorage()
# Get filename here.
fileitem = form['filename']
# Test if the file was uploaded
if fileitem.filename:
# strip leading path from file name to avoid
# directory traversal attacks
fn = os.path.basename(fileitem.filename)
open('C:/Apache24/htdocs/tmp/' + fn, 'wb').write(fileitem.file.read())
message = 'The file "' + fn + '" was uploaded successfully'
path = 'C:/Apache24/htdocs/tmp/' + fn
image = Image.open('C:/Apache24/htdocs/tmp/' + fn)
image.show()
else:
message = 'No file was uploaded'
#Content-Type: text/html\n
print ("""\
Content-Type: image/jpg\n
%s
""" % (message,path,fn,))
< /code>
ожидаемый выход: < /strong> он должен отображать изображение, взятое из указанного пути.
фактический выход: отображение с блоком IMG с текстом c: /apache24/htdocs/tmp/xy.jpg
Подробнее здесь: https://stackoverflow.com/questions/479 ... ing-python
Мобильная версия