Python Framework for Symbian Series 60 phones

Thursday 15 February 2007

Upload file to URL with multipart/form-data

First of all make sure to download HTTPFileUploader and install in as a library.

Client source:

import os
from HTTPFileUploader import * # uploader class
# path of the file to download
filePath = "001.jpg"
# new HTTPFileUploader instance
uploader = HTTPFileUploader('', port = 80) # port optional if 80
# set page
# Add fields in HTTP: ex file name for or past example
uploader.setField("fileName", os.path.split(filePath)[1])
# upload file - returns True or False.
if not uploader.uploadFile(filePath, "picture"):
    print uploader.getResult()

Server source (file_uploader.php):

# Copyright (c) 2007 LEFEVRE Damien
# file_uploader.php implementation
// In this example a directory "images" needs to be present on the same directory where
// image_uploader.php is, with the necessary rights for the script to write data inside
$content_dir = 'images/';
$filename = Null;
    $filename = $_POST['fileName'];
    if ($filename == Null){
        $filename = $_FILES['picture']['name'];
    if( !move_uploaded_file($_FILES['picture']['tmp_name'], $content_dir . $filename) ){
        exit("Couldn't write the file in $content_dir");
    // something when wrong
// return
echo "True";

Tuesday 13 February 2007

avkon.mbm image list

Here are the avkon.mbm images list with their associated tags.

Lire la suite

Friday 9 February 2007

Upload Image to URL

Many people have been asking for help. Here is a working example of an image uploader:

Python script:

# Copyright (c) 2007 LEFEVRE Damien
# image uploader: python implementation
import httplib, urllib
import base64, os.path
def imageToURL( aPath ):
    # read the binary data of the picture
    data = open(aPath, 'rb').read()
    # encoded it to base64
    encodedData = base64.encodestring( data )
    headers = { "Content-type": "application/x-www-form-urlencoded",
                "Accept": "text/plain",
    params = urllib.urlencode({ u'fileName': os.path.split(aPath)[1],
    conn = httplib.HTTPConnection( "" )
    conn.request( "POST", "/uploaderFolder/image_uploader.php", params, headers )
    response = conn.getresponse( )
    # returns "True" or "False" if failed
    print )
    # status for debugging
    print response.status
    conn.close( )
if __name__ == "__main__":

Now the image uploader (image_uploader.php):

// Copyright (c) 2007 LEFEVRE Damien
// image_uploader.php implementation
// In this example a directory "images" needs to be present on the same directory where
// image_uploader.php is, with the necessary rights for the script to write data inside
    $filename = $_POST['fileName'];
    // if not: just stop here
    print "False";
    $encodedData = $_POST['data'];
    $data = base64_decode($encodedData);
    // if not: just stop here
    print "False";
// full path for the image
$filepathname = 'images/'.$filename;
// write the file to the server into the images directory
$handle = fopen($filepathname, 'wb');
fputs($handle, $data, strlen($data));
// return
echo "True";

Tuesday 6 February 2007


There has been some good improvements on the last weeks. First of all the unofficial recompiled version of PyS60 (cycke64) with the corrected font bug with the text object on canvas. I forgot the name of the developer that found the solution. I'll mention him when I find.

With the fix bug, I'm been able to test the client on the N91 with the WiFi. So nothing to modify in the code and everything works like a dream :) The only problem is when the connection fails, it is not properly cleaned and it will not prompt the dialog for selecting the access point again, but the wrong access point remains. So I have to find a wait to catch the exception and clean it properly.

On the 24th of January, one of the best thing happened to me: I received a nice email from the NOKIA Forum announcing me that I've been selected to be part of the 22 new Forum NOKIA Champions (FNC). A nice adventure starts for that also and it will for sure help me to gain a consequent knowledge on Symbian. So I'm proud to display the following logo:


Also I made a new module containing a C++ wrapper to the native wait dialog. It's usage is:

import e32
from dialog import wait
dlg = wait(u"Hello Wait note :)")

And for 3 seconds you'll see:

  • 2nd Edition:

Wait Dialog 2nd edition

  • 3rd Edition:

Wait Dialog 3rd edition

I'm now working on the progress bar wrapper.

With the client we investigated operation on the server and we can now login, get the useful URL for the user and retrieve some XML files. We are still having difficulties with the server because there's an error while trying to retrieve user articles list. We are now working on that.