Skip to content

Instantly share code, notes, and snippets.

@Chris927
Created March 9, 2012 07:05
Show Gist options
  • Select an option

  • Save Chris927/2005412 to your computer and use it in GitHub Desktop.

Select an option

Save Chris927/2005412 to your computer and use it in GitHub Desktop.
HTML5 / pure javascript to post the 'modified date' when uploading a file
<!doctype html>
<html>
<head>
<title>Just testing...</title>
</head>
<body>
<script type="text/javascript">
function updateFile() {
var files = document.getElementById("uploadInput").files;
var nFiles = files.length;
document.getElementById("for_hidden_fields").innerHTML = "<input type=\"hidden\" name=\"modified_at\" value=\""
+ encodeURIComponent(files[0].lastModifiedDate)
+ "\" />";
};
</script>
<form name="uploadForm" action="post_files" method="POST" enctype="multipart/form-data">
<div id="for_hidden_fields"></div>
<input type="file" name="myFile" id="uploadInput" onchange="updateFile();" />
<input type="submit" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment