Skip to content

Instantly share code, notes, and snippets.

@0xPr0xy
Created November 12, 2012 17:47
Show Gist options
  • Select an option

  • Save 0xPr0xy/4060814 to your computer and use it in GitHub Desktop.

Select an option

Save 0xPr0xy/4060814 to your computer and use it in GitHub Desktop.
with hack to prevent the fakepath :D
<html>
<head>
<style>
#file{
display:none;
}
</style>
</head>
<body>
<div id="file"><img src="http://www.geeksquad.nl/client/geeksquad/images/geek-squad-logo.png"/></div>
<form enctype='multipart/form-data' action='fileupload.php' method='post'>
<input type="file" name="file"></input>
<input type='submit' value='Upload'></input>
</form>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
var wrapper = $('<div/>').css({height:0,width:0,'overflow':'hidden'});
var fileInput = $(':file').wrap(wrapper);
fileInput.change(function(){
$this = $(this);
$hackedvalue = $this.val().replace('fakepath','');
$('#file').text($hackedvalue);
})
$('#file').click(function(){
fileInput.click();
}).show();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment