Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
- function gotFS(fileSystem) {
- // The filesystem is associated with the app's origin.
- var part = localStorage.uploadPath;
- var part2 = part.substring(part.indexOf("VID"));
- var path = "/mnt/sdcard/DCIM/Camera/"+part2;
- fileSystem.root.getFile(path, null, gotFileEntry, fail);
- }
- function gotFileEntry(fileEntry) {
- fileEntry.file(function(file){
- localStorage.filename = file.name;
- localStorage.filepath = file.fullPath;
- url = "http://192.168.38.122/langator/?q=server"; // Services endpoint
- var result;
- var data;
- var reader = new FileReader();
- reader.onloadend = function(evt) {
- console.log("read success");
- result = evt.target.result;
- };
- reader.readAsDataURL(file);
- data = {
- "file" : result,
- "filename" : localStorage.filename,
- }
- drupalPostFile(data, url, postwith);
- }, function(error){
- alert("Error is "+error);
- });
- }
- function fail(error) {
- alert("An error has occurred: Code = " + error.code);
- }
- function drupalPostFile(d, url, successFunction) {
- var url = url + '/file.json';
- $.ajax({
- url : url,
- type : "POST",
- data : d,
- contentType: false,
- processData: false,
- success : function(data) {
- alert("Success file upload ");
- successFunction(data);
- },
- error : function(e) {
- alert("Error file upload " + e.status);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement