         data.append("object_id", objectId)
         data.append("attached_file", file)
 
-        xhr = new XMLHttpRequest()
         xhr.upload.addEventListener("progress", uploadProgress, false)
         xhr.addEventListener("load", uploadComplete, false)
         xhr.addEventListener("error", uploadFailed, false)

                    data = {}

                model =  $model.make_model(urlName, data)
                defered.resolve(model)

        uploadFailed = (evt) =>
            $rootScope.$apply ->

            defered.reject(response)
            return defered.promise

        xhr = new XMLHttpRequest()

        uploadProgress = (evt) =>
            $rootScope.$apply =>
                file.status = "in-progress"
