Skip to content

Instantly share code, notes, and snippets.

@ffflabs
Created August 18, 2014 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ffflabs/7bd9b9df91bb108f10c9 to your computer and use it in GitHub Desktop.
Save ffflabs/7bd9b9df91bb108f10c9 to your computer and use it in GitHub Desktop.
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script>
function removeFile()
{
var input = document.getElementById("fileToUpload");
input.value = input.defaultValue;
refreshForm();
return false;
}
function refreshForm()
{
var input = document.getElementById("fileToUpload");
if (input.files.length > 0)
{
console.log('set visible');
$("#upack-form > #remove-lnk").css("visibility", "visible");
}
else
{
console.log('set hidden');
$("#upack-form > #remove-lnk").css("visibility", "hidden");
}
}
</script>
<div class="package">
<form id="upack-form" action="/update_package" enctype="multipart/form-data" method="post">
<label>
<input id="fileToUpload" type="file" name="file" style="width: 280px; overflow: hidden;" single onChange="refreshForm();" />
&nbsp;&nbsp;&nbsp;&nbsp;
</label>
<a id="remove-lnk" style="visibility: hidden;" onclick="return removeFile();">remove</a>
</form>
</div>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment