View
 

Image Upload using JQuery and Python

Page history last edited by AveMaria 1 year ago

I saw many questions about how to upload Images to a Server...but no Tutorial how to do it. Here is how I did it using JQuery and Python.

 

Follow this tutorial iPhone: Camera API

 

Now replace the success function with the following:

 

function getPicture_Success(imageData)

{ 

    var feedURL = APIPATH + "photos/iphone-upload/";

    $.post(feedURL, {imageData:imageData}, function(data){

    });

 

In Python (Django):

def iphone_upload(request):

    import base64

    data = base64.b64decode(request.POST.get("imageData"))

    fileout = "/var/www/test.jpg"

    f1 = open(fileout,'wb+')

    f1.write(data)

    f1.close()

 

I hope this helps. I am just getting started with Phonegap (thnx for this great Project ;) ) and will be posting other tutorials as I go along. Follow me on twitter: http://www.twitter.com/scalar