Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't upload file to App Engine "list index out of range"
    text
    copied!<p>I am trying to updload a picture from a Phonegap application to my Python App Engine project. The phone app trys to upload the file but App engine returns a "list index out of range" error.</p> <p>I have the following code on the App Engine side to handle the files,</p> <pre><code>class UploadHandler(blobstore_handlers.BlobstoreUploadHandler): def post(self): upload_files = self.get_uploads('file') blob_info = upload_files[0] self.redirect('/serve/%s' % blob_info.key()) </code></pre> <p>And the following code on the PhoneGap side to send the file,</p> <pre><code> function uploadImage() { var smallImage = document.getElementById('cameraImage'); if (smallImage.src &amp;&amp; smallImage.src !== "") { var f = new FileTransfer(); f.upload(smallImage.src, "http://testtest.appspot.com/upload", // success callback function(result) { document.getElementById('uploadProgress').innerHTML = result.bytesSent + ' bytes sent'; alert(result.responseCode + ": " + result.response); }, // error callback function(error) { alert('error uploading file: ' + error.code); }, // options { fileName: 'myImage.jpg', params: { 'username':'jtyberg' } }); } } </code></pre> <p>The error is as follows,</p> <pre><code>"POST /upload HTTP/1.1" 500 487 - "BlackBerry9550/5.0.0.469 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/-1" "testtest.appspot.com" ms=416 cpu_ms=93 api_cpu_ms=0 cpm_usd=0.014221 loading_request=1 instance=00c61b117ca6c4ea405471eea592a8f79ac6 E 2011-08-06 11:49:17.309 list index out of range Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 702, in __call__ handler.post(*groups) File "/base/data/home/apps/s~testtest/1.352363227571120815/main.py", line 62, in post blob_info = upload_files[0] IndexError: list index out of range </code></pre> <p>When I try to upload a file via a web form it works great.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload