DISCONTINUATION OF PROJECT.
This project will no longer be maintained by Intel.
Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.
Intel no longer accepts patches to this project.
If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. DISCONTINUATION OF PROJECT. This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. In an effort to support the developer community, Intel has made this project available under the terms of the Apache License, Version 2. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project.
For uploading files to an appropriately configured server.
The file object gives applications the ability to upload files to a remote server.
- cancelUpload — This method cancels a previous file.uploadToServer command.
- uploadToServer — This method uploads files to a remote server over the Internet
- intel.xdk.file.upload — Fired once the file.uploadToServer method is complete
- intel.xdk.file.upload.busy — Fired when accessing the file upload is blocked by another process
- intel.xdk.file.upload.cancel — Fired if the file upload has been interrupted/cancelled
This method cancels a previous file.uploadToServer command.
intel.xdk.file.cancelUpload();This command may be used to cancel a file.uploadToServer command.
- Apple iOS
- Google Android
//Get the image to upload
var pictureURL=intel.xdk.camera.getPictureURL(pictureFilename);
intel.xdk.file.uploadToServer(pictureURL,"http://www.yourserver.com/uploadImage.
php", "", "image/jpeg", "updateUploadProgress");
function updateUploadProgress(bytesSent,totalBytes)
{
if(totalBytes>0)
currentProgress=(bytesSent/totalBytes)*100;
document.getElementById("progress").innerHTML=currentProgress+"%";
}
function cancelUpload()
{
intel.xdk.file.cancelUpload();
}
document.addEventListener("intel.xdk.file.upload.busy",uploadBusy);
document.addEventListener("intel.xdk.file.upload",uploadComplete);
document.addEventListener("intel.xdk.file.upload.cancel",uploadCancelled);
function uploadBusy(evt)
{
alert("Sorry, a file is already being uploaded");
}
function uploadComplete(evt)
{
if(evt.success==true)
{
alert("File "+evt.localURL+" was uploaded");
}
else {
alert("Error uploading file "+evt.message);
}
}
function uploadCancelled(evt)
{
alert("File upload was cancelled "+evt.localURL);
}This method uploads files to a remote server over the Internet
intel.xdk.file.uploadToServer(localURL, uploadURL, folderName, mimeType,
uploadProgressCallback);Use this command to upload a file to a server on the Internet.
- Apple iOS
- Google Android
- localURL: The URL of the file on the local device server. This URL will
always start with
http://localhost:58888/. - uploadURL: The remote server address that the file will be uploaded to
- folderName: The name of the folder on the remote server to hold the transferred file
- mimeType: The mime type of the file to be uploaded
- uploadProgressCallback: The function named here is called repetitively as the file uploads. The function should include two parameters. The first will be the number of bytes sent so far and the second will be the total bytes to be uploaded.
//Get the image to upload
var pictureURL=intel.xdk.camera.getPictureURL(pictureFilename);
intel.xdk.file.uploadToServer(pictureURL,
"http://www.yourserver.com/uploadImage.php", "", "image/jpeg",
"updateUploadProgress");
function updateUploadProgress(bytesSent,totalBytes)
{
if(totalBytes>0)
currentProgress=(bytesSent/totalBytes)*100;
document.getElementById("progress").innerHTML=currentProgress+"%";
}
document.addEventListener("intel.xdk.file.upload.busy",uploadBusy);
document.addEventListener("intel.xdk.file.upload",uploadComplete);
document.addEventListener("intel.xdk.file.upload.cancel",uploadCancelled);
function uploadBusy(evt)
{
alert("Sorry, a file is already being uploaded");
}
function uploadComplete(evt)
{
if(evt.success==true)
{
alert("File "+evt.localURL+" was uploaded");
}
else {
alert("Error uploading file "+evt.message);
}
}
function uploadCancelled(evt)
{
alert("File upload was cancelled "+evt.localURL);
}Fired once the file.uploadToServer method is complete
Fired when accessing the file upload is blocked by another process
Fired if the file upload has been interrupted/cancelled