FILEUPLOAD PUBLIC CLASS DEFINITION =================================
771476
function (element, options) {
    this.$element = $(element)
    
    this.$input = this.$element.find(':file')
    if (this.$input.length === 0) return

    this.name = this.$input.attr('name') || options.name

    this.$hidden = this.$element.find('input[type=hidden][name="' + this.name + '"]')
    if (this.$hidden.length === 0) {
      this.$hidden = $('<input type="hidden">').insertBefore(this.$input)
    }

    this.$preview = this.$element.find('.fileinput-preview')
    var height = this.$preview.css('height')
    if (this.$preview.css('display') !== 'inline' && height !== '0px' && height !== 'none') {
      this.$preview.css('line-height', height)
    }
        
    this.original = {
      exists: this.$element.hasClass('fileinput-exists'),
      preview: this.$preview.html(),
      hiddenVal: this.$hidden.val()
    }
    
    this.listen()
  }
371355
public function upload()
	{
		$response = array('uploaded' => false);

		foreach ((array)$_FILES as $file) {
			$targetFolder = isset($_POST['folder']) ? $_POST['folder'] : '/';
			$response = array_merge($response, $this->uploadFile($file, $targetFolder . '/'));
		}
        $this->returnJson($response);
	}
180302
function onFile(__newFile, encoding, done) {
  var buffers = [];
  var options = this.options;

  // Check the file limit
  if (options.perMaxBytes && __newFile.byteCount > options.perMaxBytes) {
    return done(new Error('The file \'' + __newFile.filename + '\' beyond size limit, only accept less than ' + options.perMaxBytes + ' bytes'));
  }

  // Check the accept content type
  if (options.acceptTypes && options.acceptTypes.indexOf(__newFile.headers['content-type']) === -1) {
    return done(new Error('Content-type of the file \'' + __newFile.filename + '\' does not accepted'));
  }

  // Determine the file descriptor-- the unique identifier.
  // Often represents the location where file should be written.
  __newFile.fd;
  var uploadDir = __newFile.fd;
  if (uploadDir.substr(0, 1) !== '/') {
    uploadDir = '/' + uploadDir;
  }

  // When then 'data' event emited, push the chunk to the buffers array.
  __newFile.on('data', function (chunk) {
    buffers.push(chunk);
  });

  // When the 'end' event emited, upload the 'buffers' to the upyun server.
  __newFile.on('end', function () {
    var buffer = Buffer.concat(buffers);
    uploadToUpyun.bind({ options })(uploadDir, buffer, __newFile, done);
  });
}
408338
function uploadMap(map, e) {
    let reader = new window.FileReader();

    reader.readAsText(e.target.files[0]);

    reader.onload = function () {
        let data = JSON.parse(event.target.result);
        map.new(data);
    };
}
155077
function _fillInputFile(element, value, next) {
        var onUploadDone = function (localPath) {
            element.type(localPath, next);
        };
        this.uploadFile(value, onUploadDone);
    }
872981
function uploadFile(file, next) {
    var uploadErr;

    self.uploadFile({
      source: file.source,
      target: file.target,
      server: options.server,
      keys: options.keys,
      tunnel: options.tunnel,
      remoteUser: options.remoteUser
    }).on('error', function (err) {
      if (!uploadErr) {
        uploadErr = true;
        next(err);
      }
    }).on('complete', function () {
      if (!uploadErr) {
        next();
      }
    });
  }
1011710
def ajax_upload(self, request, folder_id=None):
        
        mimetype = "application/json" if request.is_ajax() else "text/html"
        content_type_key = 'content_type'
        response_params = {content_type_key: mimetype}
        folder = None
        if folder_id:
            try:
                # Get folder
                folder = Folder.objects.get(pk=folder_id)
            except Folder.DoesNotExist:
                return HttpResponse(json.dumps({'error': NO_FOLDER_ERROR}),
                                    **response_params)

        # check permissions
        if folder and not folder.has_add_children_permission(request):
            return HttpResponse(
                json.dumps({'error': NO_PERMISSIONS_FOR_FOLDER}),
                **response_params)
        try:
            if len(request.FILES) == 1:
                # dont check if request is ajax or not, just grab the file
                upload, filename, is_raw = handle_request_files_upload(request)
            else:
                # else process the request as usual
                upload, filename, is_raw = handle_upload(request)

            # Get clipboad
            # TODO: Deprecated/refactor
            # clipboard = Clipboard.objects.get_or_create(user=request.user)[0]

            # find the file type
            for filer_class in media_settings.MEDIA_FILE_MODELS:
                FileSubClass = load_object(filer_class)
                # TODO: What if there are more than one that qualify?
                if FileSubClass.matches_file_type(filename, upload, request):
                    FileForm = modelform_factory(
                        model=FileSubClass,
                        fields=('original_filename', 'owner', 'file')
                    )
                    break
            uploadform = FileForm({'original_filename': filename,
                                   'owner': request.user.pk},
                                  {'file': upload})
            if uploadform.is_valid():
                file_obj = uploadform.save(commit=False)
                # Enforce the FILER_IS_PUBLIC_DEFAULT
                file_obj.is_public = settings.MEDIA_IS_PUBLIC_DEFAULT
                file_obj.folder = folder
                file_obj.save()
                # TODO: Deprecated/refactor
                # clipboard_item = ClipboardItem(
                #    clipboard=clipboard, file=file_obj)
                # clipboard_item.save()
                json_response = {
                    'thumbnail': file_obj.icons['32'],
                    'alt_text': '',
                    'label': str(file_obj),
                    'file_id': file_obj.pk,
                }
                return HttpResponse(json.dumps(json_response),
                                    **response_params)
            else:
                form_errors = '; '.join(['%s: %s' % (
                    field,
                    ', '.join(errors)) for field, errors in list(uploadform.errors.items())
                ])
                raise UploadException(
                    "AJAX request not valid: form invalid '%s'" % (form_errors,))
        except UploadException as e:
            return HttpResponse(json.dumps({'error': str(e)}),
                                **response_params)
1267572
function ($placeholder, file, that) {
				$.ajax({
					type: "post",
					url: that.options.imagesUploadScript,
					xhr: function () {
						var xhr = new XMLHttpRequest();
						xhr.upload.onprogress = that.updateProgressBar;
						return xhr;
					},
					cache: false,
					contentType: false,
					complete: function (jqxhr) {
						that.uploadCompleted(jqxhr, $placeholder);
					},
					processData: false,
					data: that.options.formatData(file)
				});
			}
1230321
def get_upload_form(self):
        """"""
        return self.form_class(self.request.POST, self.request.FILES)
940973
function(file) {
		if (plupload.typeOf(file) === 'string') {
			file = this.getFile(file);
		}
		this.uploader.removeFile(file);
	}
1181627
function (files) {
      UI.widgets.uploadFiles(kb.fetcher, files, subject.uri, subject.uri, function (file, uri) {
        // A file has been uploaded
        let destination = kb.sym(uri)
        console.log(' Upload: put OK: ' + destination)
        kb.add(subject, ns.ldp('contains'), destination, subject.doc())
        mainTable.refresh()
      })
    }
804266
public function doUpload()
    {
        $disk = \Storage::disk($this->getOption('disk'));
        $file = \Input::file('file');

        $ext = $file->getClientOriginalExtension() ?: $file->guessClientExtension();

        $filename = md5_file($file->getRealPath()).'.'.$ext;
        $put_path = trim($this->getOption('path'), ' /').'/'.$filename;

        if (!$disk->exists($put_path)) {
            $f_res = fopen($file->getRealPath(), 'r');
            $disk->put($put_path, $f_res);
            fclose($f_res);
        }

        return [
            'errors'        => [],
            'path'          => trim($put_path, '/'),
            'filename'      => trim($put_path, '/'),
            'original_name' => $file->getClientOriginalName(),
        ];
    }
827031
function uploadToUpyun(path, file, __newFile, done) {
  var options = this.options;
  var upyun = getInstance(options);
  upyun.uploadFile(path, file, __newFile.headers['content-type'], true, function (err, data) {
    if (err) {
      return done(err);
    }
    if (!data) {
      return done(new Error('Upload failed!'));
    }
    if (data && data.statusCode != 200) {
      return done(new Error(data.error['message']));
    }
    __newFile.fd = options.domain + path;
    return done();
  });
}
711698
public function upload()
    {
        $uploaded_files = request()->file('upload');
        $error_bag = [];
        $new_filename = null;

        foreach (is_array($uploaded_files) ? $uploaded_files : [$uploaded_files] as $file) {
            try {
                $new_filename = $this->lfm->upload($file);
            } catch (\Exception $e) {
                Log::error($e->getMessage(), [
                    'file' => $e->getFile(),
                    'line' => $e->getLine(),
                    'trace' => $e->getTraceAsString()
                ]);
                array_push($error_bag, $e->getMessage());
            }
        }

        if (is_array($uploaded_files)) {
            $response = count($error_bag) > 0 ? $error_bag : parent::$success_response;
        } else { // upload via ckeditor 'Upload' tab
            if (is_null($new_filename)) {
                $response = $error_bag[0];
            } else {
                $response = view(Lfm::PACKAGE_NAME . '::use')
                    ->withFile($this->lfm->setName($new_filename)->url());
            }
        }

        return $response;
    }
409891
@POST
	@Path("/upload")
	@Consumes("multipart/form-data")
	@AllowSecurityBypassedByToken
	public void upload(MultipartFormDataInput input) throws IOException {
		Map<String, List<InputPart>> formDataMap = input.getFormDataMap();
		List<InputPart> inputParts = formDataMap.get("uploadedFile");

		for (InputPart inputPart : inputParts) {
			String fileName = getFileName(inputPart.getHeaders());
			InputStream inputStream = inputPart.getBody(InputStream.class, null);
			File file = File.createTempFile(HomeWS.class.getSimpleName(), ".tmp");
			IOUtils.copy(inputStream, new FileOutputStream(file));
			uploadedFiles.put(fileName, file);
		}
	}
821490
async function _uploadFiles(dir, presignedPosts) {
  const promises = [];
  const limit = pLimit(5);
  let uploaded = false;

  Object.keys(presignedPosts).forEach(async (path) => {
    const { post } = presignedPosts[path];

    if (!post) {
      Logger.tagged('exists', path, 'blue');
    } else {
      const filePath = resolve(dir, path);
      const form = new FormData();

      Utils.forEach(post.fields, (value, key) => { form.append(key, value); });
      form.append('file', fs.createReadStream(filePath));

      const promise = limit(() => got.post(post.url, { body: form }).then(() => {
        Logger.tagged('upload', path);
      }));

      promises.push(promise);
      uploaded = true;
    }
  });

  await Promise.all(promises);
  return uploaded;
}
69999
function(selector, filename, done) {
    this.debug('Upload ' + filename + ' to ' + selector);
    getPage(function(page) {
      page.uploadFile(selector, filename, done);
    });
      done();
  }