Skip to content

Instantly share code, notes, and snippets.

@jeremyjbowers
Created February 20, 2013 21:25
Show Gist options
  • Save jeremyjbowers/4999773 to your computer and use it in GitHub Desktop.
Save jeremyjbowers/4999773 to your computer and use it in GitHub Desktop.
A form which will upload to an Amazon S3 bucket.
<html>
<head>
<title>Upload a file to S3</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<h1>Upload a file to S3</h1>
<form action="http://bucket.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
<input id="uploadedkey" type="hidden" name="key" />
<input type="hidden" name="success_action_redirect" value="thanks.html">
<input type="hidden" name="acl" value="public-read" />
<input name="file" type="file" id="uploadedfile" />
<input class="btn" name="submit" value="Upload" type="submit" />
</form>
<script type="text/javascript">
$('form').on('submit', function(){
var file = $('#uploadedfile')[0].files[0];
$('#uploadedkey').attr('value', file.name);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment