Here is the upload code in python:
Expand|Select|Wrap|Line Numbers
- ####
- import httplib, urllib
- f = open(r"/home/cens/einstein.gif",'rb')
- #test image
- params = urllib.urlencode({'image': f.read() })
- headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "image/gif"}
- conn = httplib.HTTPConnection("pytest.no-ip.info")
- conn.request("POST", "/upload.php", params, headers)
- response = conn.getresponse()
- ###
###
...
[PHP]$uploaddir = '/home/cens/www/uploads/';
echo '<pre>';
$uploadfile = $uploaddir . "new.gif";
$imgcontent = urldecode($_POS T['image']);
$fh = fopen($uploadfi le, 'wb') or die("can't open file");
fwrite($fh, $imgcontent);
fclose($fh);[/PHP]
##
EDIT: On an additional note, I also wrote some HTML code that feeds directly into the PHP file, and the images that I recieve through this method are fine, and display without any problems (this is what led me to believe the problem lied in the encoding part in the first place).
Thanks for the help!