This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<form id="fileupload" name="fileupload" enctype="multipart/form-data" method="post"> | |
<fieldset> | |
<input type="file" name="filename" id="filename"></input> | |
<input id="uploadbutton" type="button" value="Upload to GCS"/> | |
</fieldset> | |
</form> | |
<script type="text/javascript"> | |
$(function() { | |
var file; | |
// Set an event listener on the Choose File field. | |
$('#fileselect').bind("change", function(e) { | |
var files = e.target.files || e.dataTransfer.files; | |
// Our file var now holds the selected file | |
file = files[0]; | |
}); | |
// This function is called when the user clicks on Upload to Parse. It will create the REST API request to upload this image to Parse. | |
$('#uploadbutton').click(function() { | |
var serverUrl = 'https://mall4g-backend.appspot.com/_ah/api/mall4g/v1.0/files/insert'; | |
$.ajax({ | |
type: "POST", | |
beforeSend: function(request) { | |
request.setRequestHeader("Content-Type", file.type); | |
}, | |
url: serverUrl, | |
data: file, | |
processData: false, | |
contentType: false, | |
success: function(data) { | |
alert("File available at: " + data.url); | |
}, | |
error: function(data) { | |
var obj = jQuery.parseJSON(data); | |
alert(obj.error); | |
} | |
}); | |
}); | |
}); | |
</script> | |
Thank you - it seems to be working now. I had used that link originally, and I'm not really sure what I changed that made it work, but it seem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment