Search code examples
pythongoogle-app-engineblobstorewebapp2

GAE Python webapp2 image upload error


I am working on a project in which i am trying to upload a image on blob store. But i am getting this error

File "C:\Users\shaizi\PycharmProjects\simpletestapp\Update.py", line 51, in post

blob_info = upload_files[0]
IndexError: list index out of range

My html form code is

<form id="signup" method="post" action="/update" enctype="multipart/form-data">

 <label>Change image:</label>
        <input type="file" name="pict" ><br>
</form>

Python Code for uploading image to Blob store:

def post(self):

    blobstore.create_upload_url('/post/signup')

    upload_files = self.get_uploads('pict')

    blob_info = upload_files[0]

Solution

  • Actually i have to set the action to Upload url.

    <form id="signup" method="post" action="/post/signup" enctype="multipart/form-data">
    
     <label>Change image:</label>
            <input type="file" name="pict" ><br>
    </form>