Skip to content

Instantly share code, notes, and snippets.

@stgoos
Forked from jacobtwlee/SendFile.js
Created January 15, 2017 15:12

Revisions

  1. @jacobtwlee jacobtwlee renamed this gist Apr 14, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @jacobtwlee jacobtwlee revised this gist Mar 31, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion SendFile
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ function sendFile(fileData) {
    processData: false,
    success: function (data) {
    if (data.success) {
    alert('Your file was successfully uploaded');
    alert('Your file was successfully uploaded!');
    } else {
    alert('There was an error uploading your file!');
    }
  3. @jacobtwlee jacobtwlee created this gist Mar 30, 2015.
    23 changes: 23 additions & 0 deletions SendFile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    function sendFile(fileData) {
    var formData = new FormData();

    formData.append('imageData', fileData);

    $.ajax({
    type: 'POST',
    url: '/your/upload/url',
    data: formData,
    contentType: false,
    processData: false,
    success: function (data) {
    if (data.success) {
    alert('Your file was successfully uploaded');
    } else {
    alert('There was an error uploading your file!');
    }
    },
    error: function (data) {
    alert('There was an error uploading your file!');
    }
    });
    }