Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Tasto Submit, primo click a vuoto su Internet Explorer.. Ok con Chrome/FF/Safari

    Salve a tutti, sono nuovo del forum e spero di trovarmi bene... Mi sono iscritto per chiedervi un parere se riuscite a risolvere questo strano problema che mi si verifica solo con Internet Explorer..

    In pratica è una tabella di Pulsanti, Campi di testo e Checkbox in un Form, che carica immagini su un server e dati in un DB, quando si manda il Submit..

    Il problema è quando si preme il tasto Submit con IE.
    Il primo click va a vuoto (Non fa nulla proprio), facendo perdere l'immagine caricata; il secondo click invece funziona, entra nel
    if( $_POST['submit']=='CARICA'),
    ma le immagini non ci sono più...
    Con Chrome/Firefox/Safari/Opera il problema non c'è, il Submit funziona al primo click e carica tutto..

    Ho provato anche a fare il submit subito dopo il caricamento delle immagini in automatico (aggiungendo l'id al form e chiamando document.getElementById("IDFORM").submit() in un metodo la cui chiamata l'avevo inserita nell'onchange dell' Input File al posto dell'onchange che è scritto qui sotto), ma nulla si blocca li...

    Stesso se metto al posto di document.getElementById("IDFORM").submit() scritto prima document.getElementById("submit").click() (aggiungendo ovviamente l'id='submit' all' Input Submit del Form)..

    Ora vi posto il codice:
    Codice PHP:
    <?php
    include "../inc/func.inc.php";
    include 
    "ainc/adm.inc.php";
    include 
    "ainc/SmartImage.class.php";

    // inizializzazione della sessione
    session_start();
    $user = new Utente();
    $user->checkSession(session_id(),$_SESSION['login']);
    adm_head("news - modifica",$user);
    $id_girone addslashes(filter_var($_GET['id'], FILTER_SANITIZE_STRING));
    $stagioneaddslashes(filter_var($_GET['y'], FILTER_SANITIZE_STRING));

    if (
    $_POST['submit'] == "CARICA"){
        echo 
    "entro"//verifica se entra nell'if
            
    .
            .  
    //codice che carica le immagini e i dati 
            
    .
    }
    .
    .
    //Codice che crea la pagina 
    .
    .
    //Inizio Form 
    echo "<form action=\""$_SERVER['PHP_SELF'] ."?id=" $id_girone"&y=" $stagione ."\" name=\"upload_immagini\" enctype=\"multipart/form-data\" method=\"post\" \">";

    ?>          
    <table>
    <thead>
    <tr>
    <th>Ord</th><th>Squadra</th><th>Stemma</th><th></th><th>Foto</th><th></th><th>Pubblicità</th><th></th><th>Pres</th><th>Reti</th>
    </tr>
    </thead>
    <tbody>
    <?
    $imgs 
    = array();
    $imgs_sql //importazione dati da tabella SQL
        
    .
            .
            . 
    //inizializzazione array $alma per ogni elemento tabella
            
    .
            .
        
    //Se ci sono immagini già inserite
        
    {        
            echo 
    "<tr><td><input name=\"ord_" $alma['nriga'] . "\" type=\"input\" align=\"center\" maxlength=\"2\" size=\"2\" onkeyup=\"if(validateNumber(event)==false){this.clear();alert('Inserisci solo cifre numeriche!');}\" value=\"" addslashes(filter_var($alma['ordine'], FILTER_SANITIZE_STRING)) . "\" /></td>";
            echo 
    "<td><input name=\"nomes_" $alma['nriga'] . "\" readonly=\"readonly\" type=\"text\" align=\"left\" size=\"9\" value=\""$alma['nome'] . "\" />";
            echo 
    "<input name=\"id_" $alma['nriga'] . "\" type=\"hidden\" value=\"mod\" /><input name=\"id_sq_" $alma['nriga'] . "\" type=\"hidden\" value=\"" $alma['ids'] . "\" /></td>";
            echo 
    "<td><input name=\"stem_" $alma['nriga'] . "\" type=\"file\" style='height: 1px;width: 1px; ' onchange=\"tstem_" $alma['nriga'] . ".value=stem_" $alma['nriga'] . ".value.replace('C:\\\\fakepath\\\\','');\" accept=\"image/*\" />";                
            echo 
    "<input id=\"tstem_" $alma['nriga'] . "\" type=\"text\" align=\"center\" readonly=\"readonly\" size=\"8\" value=\"" $alma['p_stemma'] . "\" /></td>";
            echo 
    "<td><input name=\"button1\" type=\"button\" value=\"Sfoglia\" onclick=\"stem_" $alma['nriga'] . ".click();\" /></td>";
            echo 
    "<td><input name=\"foto_" $alma['nriga'] . "\" type=\"file\" style='height: 1px;width: 1px; overflow:hidden;' onchange=\"tfoto_" $alma['nriga'] . ".value=foto_" $alma['nriga'] . ".value.replace('C:\\\\fakepath\\\\','');\" accept=\"image/*\" />";
            echo 
    "<input name=\"tfoto_" $alma['nriga'] . "\" type=\"text\" align=\"center\" readonly=\"readonly\" size=\"8\" value=\"" $alma['p_foto'] . "\" /></td>";
            echo 
    "<td><input name=\"button2\" type=\"button\" value=\"Sfoglia\" onclick=\"foto_" $alma['nriga'] . ".click();\" /></td>";
            echo 
    "<td><input name=\"pubb_" $alma['nriga'] . "\" type=\"file\" style='height: 1px;width: 1px; overflow:hidden;' onchange=\"tpubb_" $alma['nriga'] . ".value=pubb_" $alma['nriga'] . ".value.replace('C:\\\\fakepath\\\\','');\" accept=\"image/*\" />";
            echo 
    "<input name=\"tpubb_" $alma['nriga'] . "\" type=\"text\" align=\"center\" readonly=\"readonly\" size=\"8\" value=\"" $alma['p_pubblicita'] . "\" /><input name=\"hpubb_" $alma['nriga'] . "\" type=\"hidden\" value=\"" addslashes(filter_var($alma['h_pubblicita'], FILTER_SANITIZE_STRING)) . "\" /><input name=\"lpubb_" $alma['nriga'] . "\" type=\"hidden\" value=\"" addslashes(filter_var($alma['l_pubblicita'], FILTER_SANITIZE_STRING)) . "\" /></td>";
            echo 
    "<td><input name=\"button3\" type=\"button\" value=\"Sfoglia\" onclick=\"pubb_" $alma['nriga'] . ".click();\" /></td>";
            echo 
    "<td><input type=\"checkbox\" name=\"pres_"$alma['nriga'] ."\" value=\"".addslashes(filter_var($alma['c_presenza'], FILTER_SANITIZE_STRING))."\"" . (addslashes(filter_var($alma['c_presenza'], FILTER_SANITIZE_STRING))==1?"checked":"") . " onclick=pres_" $alma['nriga'] . ".value=(pres_" $alma['nriga'] . ".value==1?0:1) /></td>";
            echo 
    "<td><input type=\"checkbox\" name=\"reti_"$alma['nriga'] ."\" value=\"".addslashes(filter_var($alma['c_reti'], FILTER_SANITIZE_STRING))."\"" . (addslashes(filter_var($alma['c_reti'], FILTER_SANITIZE_STRING))==1?"checked":"") . " onclick=reti_" $alma['nriga'] . ".value=(reti_" $alma['nriga'] . ".value==1?0:1) /></td></tr>";
        }
        else{
            
    $sq = array();
            
    $sq_sql =  //importazione id e nome delle squadre che interessano per la tabella immagini
            
    if(mysql_num_rows($sq_sql) > 0){
              
    // estrazione dei record tramite ciclo
                
    $i=0;
                while(
    $sq_obj $data->estrai($sq_sql)){
                    
    $i $i +1;
                    
    $nriga str_pad((int) $i,3,"0",STR_PAD_LEFT);
                    echo 
    "<tr><td><input name=\"ord_" $nriga "\" type=\"input\" align=\"center\" maxlength=\"2\" size=\"2\" onkeyup=\"if(validateNumber(event)==false){this.clear();alert('Inserisci solo cifre numeriche!');}\" /></td>";
                    echo 
    "<td><input name=\"nomes_" $nriga "\" readonly=\"readonly\" type=\"text\"  align=\"left\" size=\"9\" value=\""$sq_obj->nome "\" />";
                    echo 
    "<input name=\"id_" $nriga "\" type=\"hidden\" value=\"new\" /><input name=\"id_sq_" $nriga "\" type=\"hidden\" value=\"" $sq_obj->id "\" /></td>";
                    echo 
    "<td><input name=\"stem_" $nriga "\" type=\"file\" style=\"opacity:0.0; -moz-opacity: 0.0; filter: alpha(opacity=00); width:1px; height:1px;\" onchange=\"tstem_" $nriga ".value=stem_" $nriga ".value.replace('C:\\\\fakepath\\\\','');\"  accept=\"image/*\" />";
                    echo 
    "<input name=\"tstem_" $nriga "\" type=\"text\"  align=\"center\" readonly=\"readonly\" size=\"8\" /></td>";            
                    echo 
    "<td><input name=\"button1\" type=\"button\" value=\"Sfoglia\" onclick=\"stem_" $nriga ".click();\" /></td>";
                    echo 
    "<td><input name=\"foto_" $nriga "\" type=\"file\" style=\"opacity:0.0; -moz-opacity: 0.0; filter: alpha(opacity=00); width:1px; height:1px;\" onchange=\"tfoto_" $nriga ".value=foto_" $nriga ".value.replace('C:\\\\fakepath\\\\','');\"  accept=\"image/*\" />";
                    echo 
    "<input name=\"tfoto_" $nriga "\" type=\"text\"  align=\"center\" readonly=\"readonly\" size=\"8\" /></td>";            
                    echo 
    "<td><input name=\"button2\" type=\"button\" value=\"Sfoglia\" onclick=\"foto_" $nriga ".click();\" /></td>";
                    echo 
    "<td><input name=\"pubb_" $nriga "\" type=\"file\" style=\"opacity:0.0; -moz-opacity: 0.0; filter: alpha(opacity=00); width:1px; height:1px;\" onchange=\"tpubb_" $nriga ".value=pubb_" $nriga ".value.replace('C:\\\\fakepath\\\\','');\"  accept=\"image/*\" />";
                    echo 
    "<input name=\"tpubb_" $nriga "\" type=\"text\" align=\"center\" readonly=\"readonly\" size=\"8\" /><input name=\"hpubb_" $nriga "\" type=\"hidden\" /><input name=\"lpubb_" $nriga "\" type=\"hidden\" /></td>";
                    echo 
    "<td><input name=\"button3\" type=\"button\" value=\"Sfoglia\" onclick=\"pubb_" $nriga ".click();\"  /></td>";
                    echo 
    "<td><input type=\"checkbox\" name=\"pres_"$nriga ."\" value=\"1\" checked onclick=pres_" $nriga ".value=(pres_" $nriga ".value==1?0:1) \></td>";
                    echo 
    "<td><input type=\"checkbox\" name=\"reti_"$nriga ."\" value=\"1\" checked onclick=reti_" $nriga ".value=(reti_" $nriga ".value==1?0:1) \></td></tr>";
                }
            }
        }
        echo 
    "</tbody></table><input name='submit' type='submit' value='CARICA' /></form>";
        
    $data->disconnetti();
    }
    </
    body>
    </
    html>
    Questo è quello che alla fine stampa nel lato client:
    codice:
    // Stampa parte iniziale della pagina, prima del FORM 
    
    <form action="/admin/almanacco.php?id=7&y=2012" name="upload_immagini" enctype="multipart/form-data" method="post" > 	 	
    		<table>
    			<thead>
    				<tr>
    					<th>Ord</th><th>Squadra</th><th>Stemma</th><th></th><th>Foto</th><th></th><th>Pubblicità</th><th></th><th>Pres</th><th>Reti</th>
    				</tr>
    			</thead>
    			<tbody>
    			<tr>
    				<td>
    					<input name="ord_001" type="input" align="center" maxlength="2" size="2" onkeyup="if(validateNumber(event)==false){this.clear();alert('Inserisci solo cifre numeriche!');}" value="1" />
    				</td>
    				<td>
    					<input name="nomes_001" readonly="readonly" type="text" align="left" size="9" value="CHIEVO" />
    					<input name="id_001" type="hidden" value="mod" /><input name="id_sq_001" type="hidden" value="110" />
    				</td>
    				<td>
    					<input name="stem_001" type="file" style='height: 1px;width: 1px; overflow:hidden;' onchange="tstem_001.value=stem_001.value.replace('C:\\fakepath\\','');" accept="image/*" />
    					<input id="tstem_001" type="text" align="center" readonly="readonly" size="8" value="-" />
    				</td>
    				<td>
    					<input name="button1" type="button" value="Sfoglia" onclick="stem_001.click();" />
    				</td>
    				<td>
    					<input name="foto_001" type="file" style='height: 1px;width: 1px; overflow:hidden;' onchange="tfoto_001.value=foto_001.value.replace('C:\\fakepath\\','');" accept="image/*" />
    					<input name="tfoto_001" type="text" align="center" readonly="readonly" size="8" value="-" />
    				</td>
    				<td>
    					<input name="button2" type="button" value="Sfoglia" onclick="foto_001.click();" />
    				</td>
    				<td>
    					<input name="pubb_001" type="file" style='height: 1px;width: 1px; overflow:hidden;' onchange="tpubb_001.value=pubb_001.value.replace('C:\\fakepath\\','');" accept="image/*" />
    					<input name="tpubb_001" type="text" align="center" readonly="readonly" size="8" value="-" />
    					<input name="hpubb_001" type="hidden" value="0.000" />
    					<input name="lpubb_001" type="hidden" value="0.000" />
    				</td>
    				<td>
    					<input name="button3" type="button" value="Sfoglia" onclick="pubb_001.click();" />
    				</td>
    				<td>
    					<input type="checkbox" name="pres_001" value="1"checked onclick=pres_001.value=(pres_001.value==1?0:1) />
    				</td>
    				<td>
    					<input type="checkbox" name="reti_001" value="1"checked onclick=reti_001.value=(reti_001.value==1?0:1) />
    				</td>
    			</tr>
    		</tbody>
    	</table>
    	<input name='submit' type='submit' value='CARICA' />
    </form>
    
    
    logout</p>
    </body>
    </html>
    Ho provato a farmi stampare l'array $_FILES appena prima dell' if($_POST...) ..
    Come pensavo... Internet Explorer non lo fa il submit la prima volta che lo clicco, (solo nel caso io abbia caricato un' immagine)... Non stampa nulla ( Array() )... E la seconda volta che clicco il Submit mi stampa l'array $_FILES vuoto:
    codice:
     
    Array ( 
           [stem_001] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 )      
           [foto_001] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) 
           [pubb_001] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) 
    )
    Mentre con Chrome funziona, stampandomi per esempio:
    codice:
    Array ( 
            [stem_001] => Array ( [name] => Chievostemma.png [type] => image/png [tmp_name] => /tmp/php6P6mta [error] => 0 [size] => 10821 )
            [foto_001] => Array (     [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 )
            [pubb_001] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) 
    )

  2. #2

    Stampa

    Quando premo il submit dopo aver caricato almeno un'immagine, non fa proprio nulla... Prima ho scritto che mi stampava Array(), invece no... Quello lo fa al primo caricamento... Lo clicca proprio a VUOTO, la prima volta, dopo che ho caricato un'immagine... Boh... Se qualcuno sa darmi qualche consiglio o ha già risolto un problema simile, io sono qui... Ringrazio tutti per il mmomento...

  3. #3
    Ho constatato che sono proprio gli Input File a incasinarmi il tutto... Non so come mai, ma se carico un'immagine, il submit non funziona, clicca a vuoto... Perdo l'immagine e col click successivo il submit funziona... Boh...
    Se carico 4 immagini, al quinto click il submit funziona, perdendo ovviamente tutte le immagini...
    Oh, se non avete consigli, io sarei portato nel nascondere il FORM se si utilizza Internet Explorer e consigliare l'installazione di Chrome o un altro Browser... Almeno mi tolgo il problema per adesso...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.