0

My HTML code:

<form action="/set_image" method="post" id="form1" runat="server" enctype='multipart/form-data'>
       <div class="fileButtons">
       <input type='file' id="imgInp" name="imgInp" accept="image/*"/>
        <input type="submit" id="submit" name="action" value="Send"/>
        <input type='button' id='remove' value='Remove' />
        </div>
    </form>

main.py:

class SetImage(webapp2.RequestHandler):
    def post(self):
        id = str(self.request.get('id'))
        image = str(self.request.get('imgInp'))
        if (image):
            set_image(id, image)
            self.response.out.write("Image Uploaded")
        else:
            self.response.out.write("No Image Selected")

I'm able to get the image , but the id is empty when I try to print it.

1 Answer 1

1

If you expect to get a post value with the name id, you need to have that as a form element somewhere in your form. Such as:

<input type="text" name="id" />

However, I would not suggest using id as a name for a form element as it might cause name clashes.

If you are trying to get the name of the file, that value is probably stored in:

id = self.request.POST.get('imgInp')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.