cancelUpload

This method cancels a previous file.uploadToServer command.

intel.xdk.file.cancelUpload();

Description:

This command may be used to cancel a file.uploadToServer command.

Platforms:

Example:


//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);
}
            
Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.