cavicchi.
scusa forse la mia domanda era un po ambigua.
faccio l'esempio completo.
il codice dell'invio immagine è questo.
la pagina che riceve l'immagine e poi esegue delle operazioni e questa.codice:$(function () { $("#select").click( function () { $("#file").get(0).click(); return false; } ); $("#file").change( function () { var files = $(this)[0].files; if ( ! files.length ) { $("#selected").html("Nessun file selezionato!"); } else { var img = new Image(); $( img ).load( function () { window.URL.revokeObjectURL( this.src ); $("#selected").html( files[0].name + "<br />" + $(this)[0].naturalWidth + " x " + $(this)[0].naturalHeight + " @ " + Math.round( files[0].size / 1024 ) + " Kb" ); $("#send").show(); $("#select").addClass("mini"); } ).attr( "src" , window.URL.createObjectURL( files[0] ) ); $("#thumb").html( img ); } } ); $("#send").click( function () { $(this).hide(); $("#select").hide(); $("#progressbar").show(); var fd = new FormData(); fd.append("file", $("#file")[0].files[0]); $.ajax({ url: "./image.php" , type: "POST" , data: fd , dataType: "json" , processData: false , xhr: function () { var xhr = $.ajaxSettings.xhr(); xhr.upload.addEventListener( "progress" , function ( evt ) { if ( evt.lengthComputable ) { $("#progressbar").attr({value: evt.loaded, max: evt.total}); } } , false ); return xhr; } }) .done( function( resp ) { $("#progressbar").hide(); $("#selected").html( resp.status ); $("#select").removeClass("mini").show(); $("#progressbar").attr({value: "0", max: "100"}); } ); } ); });
per ora non fa niente e solo di prova.
questo codice fa si che io abbia un upload immagine con anteprima, quando faccio invia immagine mostra una barra di progresso, quando ha inviato tutto stampa nel div selected "nome immagine".codice:<?php $json = json_encode( array( "nome" => "nome immagine" ) ); echo $json; ?>
ora quello che vorrei capire come fare (sempre se e possibile farlo).
e prendere questa stringa "nome immagine" ritornata dal json e inviarla a un altra pagina come valore di un campo hidden.
spero di essere stato piu chiaro
senno riprovo a formulare la domanda


Rispondi quotando