Xstatic
Xstatic

Reputation: 1689

Sending an image from html to python script through CGI

I have a file input element on my HTML page like so :

input type="file"

which receives the path to an image file chosen by the user.

I need to pass this image to a python script for the remainder of the processing. How do I go about doing this? I'm familiar with CGI and its working. I am unclear on how I would send the image per se.

Thanks for your help!

Upvotes: 1

Views: 2000

Answers (1)

Christophe
Christophe

Reputation: 2012

You have to set the "enctype" field:

<form enctype="multipart/form-data" action="save_file.py" method="post">

in your HTML form. it is unclear whether you did or not, since you only provided partial information. Please have a look at http://webpython.codepoint.net/cgi_file_upload for a detailed explanation on how to proceed.

Upvotes: 2

Related Questions