db
unread,Jun 12, 2012, 6:41:40 PM6/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Titanium Desktop Transition
Peter,
This is how I did it in the past:
function saveImage() {
var desktop = Ti.Filesystem.getDesktopDirectory();
var filename = (new Date()).getTime() + ".png";
var drawing = document.getElementById('drawing');
var baseImg = drawing.toDataURL("image/png").replace("data:image/
png;base64,", "");
writeBase64Asset(desktop + "/" + filename, baseImg);
return desktop + "/" + filename;
}
the function "writeBase64Asset" is a php command. Here is the code for
it:
function writeBase64Asset($path, $data) {
return file_put_contents($path, base64_decode($data));
}
Add it to a file (e.g. base64write.php) and make sure you include the
following code:
Titanium.include("php/base64write.php");
@davidbankier