Ciao a tutti ho una pagina di un sito web con un form che permette agli utenti di caricare delle foto dal prorio server locale tramite un campo di <input type="file"/>. Le immagini che selezionano devono essere caricate in una tabella di Mysql per poterle poi ogni volta riprendere e inserire in una pag html!!!
Guardando in giro mi pare di aver capito che dovrei utilizzare un campo di tipo blob nella tabella dove salvare i dati dell'immagine, però tutti gli es che ho visto utilizzano php.. Si può fare la stessa cosa con ajax?
Per adesso ho scritto:
codice:
<html>     
<head>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">         <title>JSP Page</title>         
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>     </head>    
 <body>         
<input type="file" id="files" name="files[]" multiple />         
<output id="list"></output>         
<p id="p"></p>     
</body> 
</html> 

<style>  
 .thumb {    
 height: 75px;     
border: 1px solid #000;    
 margin: 10px 5px 0 0;   } 
</style> 

<script>  
function handleFileSelect(evt) {      
var files = evt.target.files; // FileList object        
 // Loop through the FileList and render image files as thumbnails.    
 for (var i = 0, f; f = files[i]; i++) {       
 // Only process image files.       if (!f.type.match('image.*')) { 
        continue;       }      
 var reader = new FileReader();       // Closure to capture the file information.       reader.onload = (function(theFile) {        
 return function(e) {           // Render thumbnail.          
 var span = document.createElement('span');                     
span.innerHTML = ['<img class="thumb" src="', e.target.result,  
 '" title="', escape(theFile.name), '"/>'].join('');           document.getElementById('list').insertBefore(span, null);        
 };     
  })(f);      
 // Read in the image file as a data URL.      
 reader.readAsDataURL(f);     }   }     document.getElementById('files').addEventListener('change', handleFileSelect, false); </script>
Come faccio ad ottenere i dati della mia immagine da salvare su my sql?