Last active
December 24, 2015 06:58
-
-
Save flrngel/6760321 to your computer and use it in GitHub Desktop.
multi fileupload using https://github.com/jfeldstein/jQuery.AjaxFileUpload.js, sexyFile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#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; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$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