Skip to content

Instantly share code, notes, and snippets.

@anil826
Created December 1, 2015 05:52
Show Gist options
  • Save anil826/0519c79e62378e067253 to your computer and use it in GitHub Desktop.
Save anil826/0519c79e62378e067253 to your computer and use it in GitHub Desktop.
showing uploaded file in iframe
$(document).on("input",".upload", function(){
var src = $(this).val();
src = src.replace("watch?v=", "v/");
src = src.replace("video/", "embed/video/");
var abc="<iframe src='my_source' width='452' height='345' scrolling='no' frameborder='no' target='_top' allowFullScreen></iframe>".replace(/my_source/g,src);
if (src.match(/(youtube|youtu|vimeo|veoh|dailymotion|kickstarter|metacafe)\.(com|be)\/((watch\?v=([-\w]+))|(video\/([-\w]+))|(projects\/([-\w]+)\/([-\w]+))|([-\w]+))/)) {
$(this).next('#thumbs').empty().append(abc);
}
else if( src.match(/^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.mp4|.MP4|.avi|.AVI|.3gp|.3GP)$/)) {
$(this).next('#thumbs').empty().append(abc);
}
else{$(this).next('#thumbs').empty();}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment