Etiqueta Posted May 22, 2012 at 02:01 PM Report #457383 Posted May 22, 2012 at 02:01 PM Boa tarde, existe maneira que quando se colocar um link de uma imagem num input, aparecer automaticamente a imagem? E só depois é que se guarda as informações na base de dados. Obrigada desde já pela ajuda Facebook: https://www.facebook.com/DeArteaZ Blog: http://arte-a-z.blogspot.com
HappyHippyHippo Posted May 22, 2012 at 02:28 PM Report #457393 Posted May 22, 2012 at 02:28 PM podes se mais explicito na tua questão ??? não deu para perceber nada do que tu disseste ?!?!? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Etiqueta Posted May 22, 2012 at 03:01 PM Author Report #457406 Posted May 22, 2012 at 03:01 PM (edited) já consegui resolver <input type="text" id="imgsrc" /> <div id="imagem"> </div> <body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript" language="javascript"></script> <script> jQuery.noConflict(); jQuery('#imgsrc').change(function(){ var img = jQuery(this).val(); jQuery('#imagem').prepend('<img src="'+img+'" />'); }); </script> </body> Edited May 23, 2012 at 09:45 AM by brunoais jQuery n é uma linguagem de programação. Javascript já o é. Facebook: https://www.facebook.com/DeArteaZ Blog: http://arte-a-z.blogspot.com
brunoais Posted May 23, 2012 at 09:46 AM Report #457543 Posted May 23, 2012 at 09:46 AM Bem... se esse código HTML funciona corretamente algo está bem errado.... "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
HappyHippyHippo Posted May 23, 2012 at 10:26 AM Report #457550 Posted May 23, 2012 at 10:26 AM testado e a funcionar <!DOCTYPE html> <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script> $(document).ready(function() { $('#imgsrc').change(function(event) { if (window.File && window.FileReader && window.FileList && window.Blob) { // Great success! All the File APIs are supported. var f = event.target.files[0]; var reader = new FileReader(); reader.onloadend = function() { $('#imagem').prepend('<img />'); $('#imagem img').attr('src', reader.result); } reader.readAsDataURL(f); var description = ''; description += '<ul>'; description += '<li>'; description += '<strong>'+escape(f.name)+'</strong>'; description += ' ('; description += f.type || 'n/a'; description += ') - '; description += f.size; description += ' bytes'; description += ', last modified: '; description += f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a'; description += '</li>'; description += '</ul>'; $('#imagem').append(description); } else { $('#imagem').html("cannot present image"); } }); }); </script> </head> <body> <input type="file" id="imgsrc" /> <div id="imagem"> </div> </body> </html> sources : http://jsfiddle.net/ugPDx/ e http://www.html5rocks.com/en/tutorials/file/dndfiles/ IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now