Skip to content

Instantly share code, notes, and snippets.

@flrngel
Last active December 24, 2015 06:58
Show Gist options
  • Save flrngel/6760321 to your computer and use it in GitHub Desktop.
Save flrngel/6760321 to your computer and use it in GitHub Desktop.
$("#fileAddBtn").click(function(){
var newfile=$("<input type='file' name='file[]'>");
$(this).parent().append("<br/>").append(newfile);
newfile.ajaxfileupload({
action: "/util/fileupload.json",
onComplete: function(response){
if( response.result ){
console.log(newfile.val());
var filename = "<span>"+newfile.val().split('\\').pop()+"</span>";
newfile.attr("type","hidden");
newfile.css("border","none");
newfile.css("background","none");
newfile.css("width","300px");
newfile.attr("value",response.data);
newfile.next().show().before(filename);
}
}
});
var newfiledel=$("<a href='#'>delete</button>");
newfiledel.hide();
$(this).parent().append(newfiledel);
newfiledel.click(function(e){
$(this).prev().remove();
$(this).prev().remove();
$(this).remove();
e.preventDefault();
return false;
});
});
<?
$sexyFile=new sexyFile;
$res=$sexyFile->upload($_FILES['file']);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment