Skip to content

Commit

Permalink
some fix
Browse files Browse the repository at this point in the history
some fix
  • Loading branch information
KuoKongQingYun committed Jan 4, 2015
1 parent 4e231c7 commit dd4cbbc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 56 deletions.
35 changes: 4 additions & 31 deletions FlashAndShare.xdk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"projectTypeName": "com.intel.xdk.projecttype.jsapp",
"src": "appDesigner",
"projectGuid": "ed855410-8d0d-4ef1-b3ff-d3c4e4de0b3a",
"lastModifiedDate": 1420300108760,
"lastModifiedDate": 1420370076146,
"creationDate": 1420291580458
},
"XDK-app-designer": "true",
Expand All @@ -33,42 +33,15 @@
"serviceMethods": [],
"cordovaPluginsDirectory": "plugins",
"cordovaPlugins": [
{
"id": "org.apache.cordova.camera",
"version": "0.2.9",
"selectedState": "Included",
"data": {},
"paramvals": {}
},
{
"id": "org.apache.cordova.splashscreen",
"version": "0.3.0",
"selectedState": "Included",
"data": {},
"paramvals": {}
},
{
"id": "org.apache.cordova.device",
"version": "0.2.9",
"selectedState": "Included",
"data": {},
"paramvals": {}
},
{
"id": "intel.xdk.camera",
"selectedState": "Included",
"data": {},
"paramvals": {}
},
{
"id": "org.apache.cordova.file",
"version": "1.1.0",
"selectedState": "Included",
"data": {},
"paramvals": {}
},
{
"id": "intel.xdk.file",
"id": "org.apache.cordova.file-transfer",
"version": "0.4.3",
"selectedState": "Included",
"data": {},
"paramvals": {}
Expand Down Expand Up @@ -96,7 +69,7 @@
"cordovaCLIVersion_": "3.5",
"crosswalkVersion_": "stable",
"appVersion_": "0.0.1",
"appDescription_": "Template to develop a cross-platform mobile app using the App Designer UI editor.",
"appDescription_": "Take photo and share!",
"appAuthor_": "",
"appVersionCode_": "1"
},
Expand Down
13 changes: 10 additions & 3 deletions www/js/taking_photo_event_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
if (event.success === true) {
var imagesrc = intel.xdk.camera.getPictureURL(event.filename);
$("#photo").attr("src", imagesrc);
intel.xdk.file.uploadToServer(imagesrc, "http://flashandshare.linzhihao.cn/uploadImage.php", "", "image/jpeg", "updateUploadProgress");
alert("");
xmlHttpRequest = createXmlHttpRequest();


var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imagesrc.substr(fileURL.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
var ft = new FileTransfer();
ft.upload(imagesrc,encodeURI("http://flashandshare.linzhihao.cn/index.php"), upload_success, upload_fail, options);
//intel.xdk.file.uploadToServer(imagesrc,"http://flashandshare.linzhihao.cn/uploadImage.php", "", "image/jpeg", "updateUploadProgress");
//xmlHttpRequest = createXmlHttpRequest();
} else {
if (event.message !== undefined) {
alert(event.message);
Expand Down
31 changes: 9 additions & 22 deletions www/js/uploading_event_handlers.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
(function() {
"use strict";
function updateUploadProgress(bytesSent, totalBytes) {
if (totalBytes > 0) currentProgress = (bytesSent / totalBytes) * 100;
document.getElementById("progress").innerHTML = currentProgress + "%";
}

function uploadBusy(evt) {
alert("Sorry, a file is already being uploaded");
}

function uploadComplete(evt) {
alert("123");
if (evt.success === true) {
alert("File " + evt.localURL + " was uploaded");
$("#URL").html(evt.localURL);
} else {
alert("Error uploading file " + evt.message);
}
function upload_success(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}

function uploadCancelled(evt) {
alert("File upload was cancelled " + evt.localURL);
function upload_fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
document.addEventListener("intel.xdk.file.upload.busy", uploadBusy);
document.addEventListener("intel.xdk.file.upload", uploadComplete);
document.addEventListener("intel.xdk.file.upload.cancel", uploadCancelled);

})();

0 comments on commit dd4cbbc

Please sign in to comment.