     success: (file) ->
       file.previewElement.classList.add "dz-success"
 
+    # When the upload is canceled.
+    canceled: (file) -> @emit "error", file, "Upload canceled."
+
     # When the upload is finished, either with success or an error.
     # Receives `file`
     complete: (file) ->

  getUploadingFiles: -> file for file in @files when file.status == Dropzone.UPLOADING


  enqueueFile: (file) ->
    if file.status == Dropzone.ACCEPTED
      file.status = Dropzone.QUEUED
      @processQueue()
    else
      throw new Error "This file can't be queued because it has already been processed or was rejected."


  init: ->
    # In case it isn't set already
    @element.setAttribute("enctype", "multipart/form-data") if @element.tagName == "form"

    i = processingLength

    queuedFiles = @getQueuedFiles()

    return unless queuedFiles.length > 0

    if @options.uploadMultiple
      # The files should be uploaded in one request
      @processFiles queuedFiles.slice 0, parallelUploads
    else
      while i < parallelUploads
        return unless queuedFiles.length # Nothing left to process
        @processFile queuedFiles.shift()
        i++


  # Wrapper for `processFiles`
  processFile: (file) -> @processFiles [ file ]


  # Loads the file, then calls finishedLoading()
  processFiles: (files) ->
    for file in files
      file.processing = yes # Backwards compatibility
      file.status = Dropzone.UPLOADING

      @emit "processingfile", file

    @uploadFiles files



  _getFilesWithXhr: (xhr) -> files = (file for file in @files when file.xhr == xhr)


  # Cancels the file upload and sets the status to CANCELED
