Photo
Navigator.camera.getPicture (onsuccess, Onfail, {quality:50, destinationtype:0,sourcetype:1});//Take photos to get Base64 pictures
function onsuccess (imageData) {
Data.newdata ({//photo complete added to data stored in image
"Defaultvalues": [{
fzid:fzid,//Primary Table ID
Imgurl: "Data:image/jpeg;base64," + Base64 code for imagedata,//pictures
imgtpye:statename,//Table State Type
phototime:datetime//Photo Time
} ]
});
}
Save to local Database
Please see previous article WebX5 sqllite additions and deletions
Http://www.cnblogs.com/pengyawn/p/4725166.html
Uploading pictures to the server
function Imgupload (names) {//upload the server's JS code
IMGURL//64 Code Image
phototime///Photo Time
custid//User ID
address//Picture Save location
for (var a=0; a<names.length;a++) {
var image = Names[a].imgurl;
var subpath= "* * *";
var name=names[a]. Custid+ "_" +names[a].phototime+ ". jpg";
var params={
image:image,/Picture Base64 Code
subpath:subpath,//Server storage Location
picname:name//file name
};
$.ajax ({//Please note the Post method using Ajax
Type: ' POST ',
url:names[a].address+ "* * *",
Data:params,
Success:success,
DataType: ' JSON '
});
}
var success = function (Resultdata) {//post-upload processing
Alert ("Upload file succeeded! ");
};
}
Background Get parameters
Import sun.misc.base64decoder;//need to configure access rules for the JRE system library
public void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {
String image = Request.getparameter ("image"). Substring (23);//Get the Base64 code of the parameter picture
The picture is stored in the location of the project at the server and then stitched to get the picture's storage location
String subpath = This.getclass (). GetResource ("/"). GetPath (). substring (1, +) + request.getparameter ("subpath");// Get Picture storage location
String picname = Request.getparameter ("Picname"). ReplaceAll ("-", "" "). ReplaceAll (": "," "). ReplaceAll (" "," ");// Get Picture Store Name
Base64decoder decoder = new Base64decoder ();//Picture base64 decrypt and save local
try {
FileOutputStream write = new FileOutputStream (new File (subpath + picname));//query picture address, create a new picture, if the address does not exist, create a new
byte[] Decoderbytes = decoder.decodebuffer (image);
Write.write (decoderbytes);
Write.close ();
} catch (IOException e) {
E.printstacktrace ();
}
}
Xiao: Chongqing King 2015-08-19 15:58
Webx.5 Photo Upload function