Python 3 and cgi. Error image download from webbrowser -
my question python 3 , web cgi. have problem when download 1 image webbrowser, image downloaded, error format. code ...
src = "../public/downloads/test.png" name = "test.png" data = open(src, 'rb').read() print("content-type: image/png;") print("content-disposition: attachment; filename="+name+";") print("content-transfer-encoding: binary;") print("content-length: " + str(os.stat(src).st_size)+";\r\n") print(data)
the problem solved:
src = "../public/downloads/test.png" name = "test.png" data = open(src, 'rb').read() print("content-type: image/png;") print("content-disposition: attachment; filename="+name+";") print("content-transfer-encoding: binary;") print("content-length: " + str(os.stat(src).st_size)+";\r\n") sys.stdout.flush() sys.stdout.buffer.write(data)
Comments
Post a Comment