Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/11/2010, 16:55
Vhyll
 
Fecha de Ingreso: octubre-2004
Ubicación: Lima, Perú
Mensajes: 185
Antigüedad: 19 años, 6 meses
Puntos: 1
Insertar Imagen mediante jquery en sistema de noticias

Buenas tengo un sistema de noticias que esta basado en PHP y Jquery, uso el ajaxupload, para subir imagenes pero mi consulta es la siguiente:
¿Como se puede insertar las imagenes que se sube en el servidor?
y a la vez se añada en el campo Textarea ( <textarea id="datos" name="datos" class="text-input"></textarea>) como se usa en blogger y wordpress, cuando suben imagenes y cuando los marcas se añade en la noticia que deseas publicar.
Este son las imagenes que se suben y cargan mediante ajax
Código HTML:
<ol id="files">
<li><img src="/imagen/4845.jpg" width="100"><br>
<a href="#" class="del">remove</a></li>
<li><img src="/imagen/4890.jpg" width="100"><br>
<a href="#" class="del">remove</a></li>
</ol> 
Y este es el Codigo que uso y se inserta en un Input, pero kisiera que se inserte en el textarea con varias imagenes que subo, ya que en la linea
<ol id="files"></ol></div> se ve la cantidad de imagenes que se sube como lo mencione mas arriba
Código Javascript:
Ver original
  1. <script src="js/ajaxupload.js" type="text/javascript"></script>
  2.  
  3.        
  4.         <script type="text/javascript">
  5.         /*<![CDATA[*/
  6.     $(document).ready(function(){
  7.  
  8.         /* Example 2 */
  9.         var count = $('#files').children('li').size();
  10.         new AjaxUpload('upload_button', {
  11.             action: 'upload.php',
  12.             data : {
  13.                 'key1' : "This data won't",
  14.                 'key2' : "be send because",
  15.                 'key3' : "we will overwrite it"
  16.             },
  17.             onSubmit : function(file , ext){
  18.                 // Allow only images. You should add security check on the server-side.
  19.                 if (ext && /^(jpg|png|jpeg|gif)$/.test(ext)){
  20.                     /* Setting data */
  21.                     this.setData({
  22.                         'key': 'This string will be send with the file'
  23.                     });                
  24.                     $('#example2 .text').text('Uploading ' + file);
  25.                 } else {                   
  26.                     // extension is not allowed
  27.                     $('#example2 .text').text('Error: only images are allowed');
  28.                     // cancel upload
  29.                     return false;              
  30.                 }  
  31.             // increment count
  32.             count ++;
  33.             // count submission
  34.             if(count > 12){
  35.                 alert('Blah blah');
  36.                 return false;
  37.             }
  38.             // showing loader
  39.             var li = $('#files').children('li').size();
  40.             if(count > li ){
  41.                 $('#loader').show();
  42.             }
  43.  
  44.                 },
  45.             onComplete: function(file, response){
  46.                
  47.            
  48.                 $('#example2 .text').text('Uploaded ' + file); 
  49.                                    
  50.                 var list_item = '<li><img src="/imagen/'+ file +'" width="100"/><br />';
  51.                     list_item += '<a href="#" class="del">remove</a></li>';        
  52.                 $('#files').append(list_item);
  53.                
  54.                
  55.                
  56.                 $('#imagen').val(file);  
  57.  
  58.                
  59.                 // remove the loader
  60.                 var li = $('#files').children('li').size();
  61.                 if(count == li){
  62.                 $('#loader').hide();
  63.                 }
  64.  
  65.            
  66.                 $('.del').click(function(e){
  67.                 e.preventDefault();
  68.                 $.post("delete.php");
  69.                 $(this).parent().remove();
  70.                 count --;
  71.                 });
  72.            
  73.             }  
  74.                
  75.        
  76.         });
  77.                
  78.     });/*]]>*/</script>
  79. <ol id="files"></ol></div>
  80.             <form id="registro" name="registro" action="">
  81.                 <div>
  82.                     <label class="campo">Imagen :</label>
  83.                     <input type="text" id="imagen" name="imagen"  class="text-input" disabled="disabled">
  84.                     <li id="example2" class="example"><a href="#" id="upload_button">Upload</a>
  85.   <img id="loader" src="img/loader.gif" style="display:none" /></li>
  86.                 </div>
  87.                 <div>
  88.                     <label class="campo">Datos</label>                        
  89.                     <textarea id="datos" name="datos" class="text-input"></textarea>
  90.                 </div>
  91.        
  92.                 <div align="center">
  93.            
  94.                 <input type="submit" class="submit"  value="Enviar" />
  95.                 <input type="button" class="button" onclick="preview_ajax()"  value="Vista Previa" />
  96.  
  97.                </div>
  98.             </form>
__________________
VkManga.Com
De todo un Poco