post https://api.fulcrumapp.com/api/v2/signatures.json
jQuery Web Form Example
<form>
<input type="file" name="signature" id="signature" /><br /><br />
<input type="button" id="upload" value="upload" />
</form>
$(document).ready(function(){
/**
* Generates a GUID string.
* @returns {String} The generated GUID.
* @example af8a8416-6e18-a307-bd9c-f2c947bbb3aa
* @author Slavik Meltser ([email protected]).
* @link http://slavik.meltser.info/?p=142
**/
function guid() {
function _p8(s) {
var p = (Math.random().toString(16)+"000000000").substr(2,8);
return s ? "-" + p.substr(0,4) + "-" + p.substr(4,4) : p ;
}
return _p8() + _p8(true) + _p8(true) + _p8();
}
$("#upload").click(function(){
var formData = new FormData();
formData.append("signature[access_key]", guid());
formData.append("signature[file]", $("#signature")[0].files[0]);
$.ajax({
type: "POST",
url: "https://api.fulcrumapp.com/api/v2/signatures.json",
data: formData,
cache: false,
contentType: false,
processData: false,
dataType: "json",
headers: {
"X-ApiToken": "my-api-key"
},
success: function (data) {
// do something!
console.log(data);
}
});
});
});