Partage
  • Partager sur Facebook
  • Partager sur Twitter

Probleme d'input

Boutton parcourire

    3 novembre 2008 à 17:34:43

    Bonjours, j'ai un problème avec un imput qui ne marche pas sur certains pc.
    Voici la ligne:
    <input type="Button" value="Parcourir..." name="flashInfoButton" onClick="javascript:browsefiles();" style="width:100px;" class="bouton" />
    

    Sur certains pc quand on clic sur parcourir rien ne se passe alors que chez moi ça marche très bien o_O
    Merci d'avance
    • Partager sur Facebook
    • Partager sur Twitter
      3 novembre 2008 à 17:42:01

      Pourquoi vouloir le faire en javascript ? Il y a les input de type file pour cela, fonctionnels sur toutes les machines. Une raison particulière pour utiliser cette méthode ?
      • Partager sur Facebook
      • Partager sur Twitter
        4 novembre 2008 à 10:32:41

        Merci pour ta réponse =).
        C'est un upload multiple, j'ai pris un code tout prêt et je l'ai adapté au mieux que je pouvais. Avec un file je ne peux selectionner qu'un seul fichier.
        • Partager sur Facebook
        • Partager sur Twitter
          4 novembre 2008 à 10:41:22

          et si on voyais plutot la fonction browsefiles()
          sa serrais peut etre mieu ;)
          • Partager sur Facebook
          • Partager sur Twitter
            4 novembre 2008 à 10:50:16

            En fait la fonction est en flash j'ai l'impression ^^
            Regardez le JS:
            /*
            flash.browseFiles(typelist) displays a file-browsing dialog box in which the user can select a local file to upload. 
            The dialog box is native to the user's operating system.
            typelist - An array of file types used to filter the files displayed in the dialog box.
            */
            function browsefiles(){
            	var allTypes = new Array();
            	var imageTypes = new Object();
            	imageTypes.description = "Envoi de documents (<?php echo $extautoriseeStr ?>)";
            	imageTypes.extension = "<?php echo $extautoriseeStr ?>";
            	allTypes.push(imageTypes);    
            	/*
            	imageTypes = new Object();
            	imageTypes.description = "Images (*.JPG;*.JPEG;*.JPE;*.GIF;*.PNG;)";
            	imageTypes.extension = "*.jpg; *.jpeg; *.jpe; *.gif; *.png;";
            	allTypes.push(imageTypes);
            	*/
            	Flash.browseFiles(allTypes);
            }
            
            • Partager sur Facebook
            • Partager sur Twitter
              4 novembre 2008 à 11:28:43

              heuuu
              sa ma pas l'air d'etre une fonction qui permet d'aller chercher sur le Pc des fichier Oo

              on sais meme pas a quoi correspond :
              Flash
              browserFiles()

              y'aurais pas d'autre fonction et d'autre boue de code Js par azard ?

              pourais tu mettre toute ta source stp avec avec le zcode <.... type="html">

              Merci

              PS: ce n'est pas du flash.
              • Partager sur Facebook
              • Partager sur Twitter
                4 novembre 2008 à 11:50:51

                Merci pour ton aide =)
                Voici le code en entier :
                <?php
                
                //----------------------------------------------------------------------------------------------------------------------------------------------------------------------
                // URL de la page d'upload des documents
                $uploadUrl = 'uploadFormProcess.php?mode=multi';
                $uploadUrlClassic = 'uploadFormProcess.php?mode=classic';
                
                //----------------------------------------------------------------------------------------------------------------------------------------------------------------------
                // Restrictions sur les poids des fichier et de l'envoi total
                
                // Paramétrage pour le développeur
                $EDOC_MAX_FILE_SIZE_octets = 9999999999999999999;
                $EDOC_MAX_FILE_TOTAL_SIZE_octets = 9999999999999999999;
                
                // Paramétrage récupéré dans le php.ini
                $MAX_FILE_SIZE_octets = return_bytes(ini_get('upload_max_filesize'));
                $MAX_FILE_TOTAL_SIZE_octets = 50000000;
                
                // Calcul des restrictions réelles (le php.ini a le dessus !)
                $tailleMaxiFichier = $MAX_FILE_SIZE_octets < $EDOC_MAX_FILE_SIZE_octets ? $MAX_FILE_SIZE_octets : $EDOC_MAX_FILE_SIZE_octets;
                $tailleMaxiFichierStr = round(($tailleMaxiFichier/1024)/1024,2);
                $tailleMaxiFichierStr .= ' Mo';
                $tailleMaxiTotale = $MAX_FILE_TOTAL_SIZE_octets < $EDOC_MAX_FILE_TOTAL_SIZE_octets ? $MAX_FILE_TOTAL_SIZE_octets : $EDOC_MAX_FILE_TOTAL_SIZE_octets;
                $tailleMaxiTotaleStr = round(($tailleMaxiTotale/1024)/1024,2);
                $tailleMaxiTotaleStr .= ' Mo';
                //echo("<br>MAX_FILE_TOTAL_SIZE_octets = $MAX_FILE_TOTAL_SIZE_octets<br>MAX_FILE_SIZE_octets = $MAX_FILE_SIZE_octets<br>EDOC_MAX_FILE_SIZE_octets = $EDOC_MAX_FILE_SIZE_octets<br>EDOC_MAX_FILE_TOTAL_SIZE_octets = $EDOC_MAX_FILE_TOTAL_SIZE_octets<br><br>tailleMaxiFichier = $tailleMaxiFichier<br>tailleMaxiTotale = $tailleMaxiTotale<br>tailleMaxiFichierStr = $tailleMaxiFichierStr<br>tailleMaxiTotaleStr = $tailleMaxiTotaleStr<br><br>");
                
                // FlashVars : paramètres de l'upload flash
                $FlashVars = 'useExternalInterface=Yes&maxFileSize='.$tailleMaxiFichier.'&maxFileSizeTotal='.$tailleMaxiTotale.'&mode=multi';
                
                // Fonction utilisée pour les ini_get : conversion de la taille
                function return_bytes($val) {
                    $val = trim($val);
                    $last = strtolower($val{strlen($val)-1});
                    switch($last) {
                        case 'g':
                            $val *= 1024;
                        case 'm':
                            $val *= 1024;
                        case 'k':
                            $val *= 1024;
                    }
                    return $val;
                }
                
                //----------------------------------------------------------------------------------------------------------------------------------------------------------------------
                // Tableau des extensions autorisées :  $extautorisee
                $extautorisee=array('jpeg','jpg','jpe','gif','png','bmp');
                
                $cpt = 0;
                $extautoriseeStr = '';
                $nbExt = count($extautorisee);
                foreach ($extautorisee as $key => $ext) {
                	$cpt ++;
                	$extautoriseeStr .= '*.'.$ext;
                	if($cpt<$nbExt){
                		$extautoriseeStr .= '\\;';
                	}
                }
                include('droit.php');
                if($_SESSION['pseudo']!=NULL)
                {
                ?>
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
                   <head>
                       <title>Ajouter des photos | Les Lézards de Lescar</title>
                       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                		<meta http-equiv="PRAGMA" content="NO-CACHE">
                	   <link rel="stylesheet" media="screen" type="text/css" title="Style1" href="css/style1.css" />
                   </head>
                   <body>
                
                <div id="haut_de_page">
                   <?php include("haut_de_page.php"); ?>
                </div>
                   
                <div id="menu">
                <?php include("menu.php");
                ?>
                </div>
                
                <div id="corps">
                
                <div class="fond_corps">
                
                <table>
                <tr><td class="hg"></td><td class="hc">Envoyez vos fichiers :</td><td class="hd"></td></tr>
                <tr><td class="mg"></td>
                <td class="mc" style="height:300px;">
                <form name="monFormulaire">
                <p>
                Choisissez dans quel dossier voulez-vous ajouter vos photos : 
                <select name="dossier" id="dossier" onchange="javascript:dossierChange()" >
                    
                	<?php
                	mysql_connect('localhost','lezardsdelescar','*******');
                	mysql_select_db('lezardsdelescar');
                	$recu=mysql_query('SELECT * FROM dossiers ORDER BY id');
                	$nulle=TRUE;
                	while($donnees=mysql_fetch_array($recu))
                	{
                	if($donnees['dossier']!=NULL)
                	{
                	echo '<option value="'.$donnees['id'].'" ';
                	if ($_GET['dossier']==$donnees['id']) 
                	echo 'selected="selected"';
                	echo '>-'.$donnees['dossier'].'</option>';
                	$nulle=NULL;
                	}
                	}
                	if($nulle)
                	{echo '<option value="0" >-------------------</option>';}
                	mysql_close();
                	?>
                	
                	<option value="new"  >Nouveau Dossier</option></select>
                	</p><p style="margin:0px;" name="inputNouveau" id="inputNouveau" class="cache">Ecrivez le nom du nouveau dossier:<input type="text" name="nouveau" id="pouet" onchange="javascript:dossierChange()"/></p></form>
                <table>
                    <tr>
                        <td align="center">
                			
                			<!-- FLASH UPLOAD CODE. START -->
                			<div id="FlashUpload" style="width:1px;height:1px;">
                			  <OBJECT id="FlashFilesUpload" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
                				<!-- Replace symbols " with the &quot; at all parameters values and 
                				symbols "&" with the "%26" at URL values or &amp; at other values!
                				The same parameters values should be set for EMBED object below. -->
                				<PARAM NAME="FlashVars" VALUE="<?php echo $FlashVars ?>">
                				<PARAM NAME="BGColor" VALUE="#F8F6E6">
                				<PARAM NAME="Movie" VALUE="ElementITMultiPowUpload1.7.swf">
                				<PARAM NAME="Src" VALUE="ElementITMultiPowUpload1.7.swf">
                				<PARAM NAME="WMode" VALUE="Window">
                				<PARAM NAME="Play" VALUE="-1">
                				<PARAM NAME="Loop" VALUE="-1">
                				<PARAM NAME="Quality" VALUE="High">
                				<PARAM NAME="SAlign" VALUE="">
                				<PARAM NAME="Menu" VALUE="-1">
                				<PARAM NAME="Base" VALUE="">
                				<PARAM NAME="AllowScriptAccess" VALUE="always">
                				<PARAM NAME="Scale" VALUE="ShowAll">
                				<PARAM NAME="DeviceFont" VALUE="0">
                				<PARAM NAME="EmbedMovie" VALUE="0">        
                				<PARAM NAME="SWRemote" VALUE="">
                				<PARAM NAME="MovieData" VALUE="">
                				<PARAM NAME="SeamlessTabbing" VALUE="1">
                				<PARAM NAME="Profile" VALUE="0">
                				<PARAM NAME="ProfileAddress" VALUE="">
                				<PARAM NAME="ProfilePort" VALUE="0">
                				<!-- Embed for Netscape,Mozilla/FireFox browsers support. Flashvars parameters are the same.-->
                				<!-- Replace symbols " with the &quot; at all parameters values and symbols "&" with the "%26" at URL values or &amp; at other values! -->
                				<embed bgcolor="#F8F6E6" id="EmbedFlashFilesUpload" src="ElementITMultiPowUpload1.7.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="1" height="1" flashvars="<?php echo $FlashVars ?>">
                				</embed>
                			  </OBJECT>
                			</div>
                			<!-- FLASH UPLOAD CODE. END -->
                 
                			<!-- JAVA SCRIPT INTERFACE CODE. START -->
                			<div align="left" id="JSUpload" style="width:600px;height:1px;visibility:hidden;">
                			  <input type="Button" value="Parcourir..." name="flashInfoButton" onClick="javascript:browsefiles();" style="width:100px;" class="bouton" /><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; padding-left:100px;">&nbsp;&nbsp;&nbsp;&nbsp;Multi-s&eacute;lection&nbsp;possible&nbsp;-&nbsp;maxi&nbsp;par&nbsp;fichier&nbsp;:&nbsp;<?php echo $tailleMaxiFichierStr ?>&nbsp;/&nbsp;maxi&nbsp;global&nbsp;:&nbsp;<?php echo $tailleMaxiTotaleStr ?></span><br>
                			  <select id="fileslist" name="fileslist" style="HEIGHT:150px;WIDTH:600px;" multiple></select>
                				<table style="border:solid 1px #000033;" width="600" height="25" cellpadding="0" cellspacing="0">
                					<tr>
                						<td>
                							<table id="rowProgress" bgcolor="#0033ff" width="1" height="25" cellpadding="0" cellspacing="0">
                								<tr>
                									<td>&nbsp;</td>
                								</tr>
                							</table>
                						</td>
                					</tr>
                				</table>
                			  <input type="Button" value="Envoyer" name="flashInfoButton" id="flashInfoButtonSubmit" onClick="javascript:this.disabled=true;upload();" style="width:100px;" class="bouton" />&nbsp;<input type="Button" value="Vider la liste" name="flashClearButton" onClick="javascript:effacerListeFichiers();" style="width:100px;" class="bouton" />
                			  <div id="lable">&nbsp;</div>
                			</div> 
                			<!-- JAVA SCRIPT INTERFACE CODE. END -->
                
                			<!-- CLASSIC UPLOAD CODE. START -->
                			<div align="left" id="ClassicUpload" style="width:600px;height:1px;visibility:hidden;">
                				<script language="javascript">
                					var classicFilesCount = 1;
                					function ShowClassicUpload()
                					{
                						InitFlashObj(); //sometimes Flash not initialized while window.onload event
                						if(Flash) //hide flash
                						{
                							Flash.width = 1;
                							Flash.height = 1;
                						}
                						var JSClassicUploadButton = document.getElementById("ClassicUploadButton");
                						if(JSClassicUploadButton) //hide flash JavaScript interface
                						{
                							JSClassicUploadButton.style.visibility = "hidden";
                						}
                						var JSUpload = document.getElementById("JSUpload");
                						if(JSUpload) //hide flash JavaScript interface
                						{
                							JSUpload.style.visibility = "hidden";
                							JSUpload.style.height = 1;
                							JSUpload.innerHTML = ""; // JSUpload willn't be available after this.
                						}
                						var ClassicUpload = document.getElementById("ClassicUpload");
                						ClassicUpload.style.visibility = "visible";
                						ClassicUpload.style.height = 200;
                						DivShowClassicUpload.style.visibility = "hidden";
                					}
                					function AddFile() //Dinamicaly add new file fields
                					{    
                						//var lastInputFile = document.getElementById("file" + classicFilesCount);
                						classicFilesCount ++;    
                						var elementNewFile = document.createElement('span');    
                						elementNewFile.innerHTML = '<input onChange="javascript: AddFile();" type="file" name="file' + classicFilesCount + '" id="file' + classicFilesCount + '" style="width:600px;" class="bouton">';
                						document.getElementById("classicFilesList").appendChild(elementNewFile);
                					}
                				</script>
                				
                			</div>
                			<!-- CLASSIC UPLOAD CODE. END -->
                			
                			</td>
                    </tr>
                </table>
                
                
                <script language="JavaScript">
                // UPLOAD
                var Flash;
                var uploadedfilescount = 0;
                var myUploadUrl = "<?php echo($uploadUrl); ?>";
                var pseudo = "<?php echo $_SESSION['pseudo']; ?>";
                var dossier = document.monFormulaire.dossier.value;
                myUploadUrl = myUploadUrl + '&dossier=' + document.monFormulaire.dossier.value + '&pseudo=' + pseudo;
                
                window.onload = function() {    
                	InitFlashObj();
                }
                
                function dossierChange(){
                dossier = document.monFormulaire.dossier.value;
                nouveau = escape(document.monFormulaire.nouveau.value);
                if(dossier == "new"){
                myUploadUrl = "<?php echo($uploadUrl); ?>";
                myUploadUrl = myUploadUrl + '&dossier=' + nouveau + '&pseudo=' + pseudo;
                document.getElementById('inputNouveau').className='visible';
                }
                else{
                myUploadUrl = "<?php echo($uploadUrl); ?>";
                myUploadUrl = myUploadUrl + '&dossier=' + dossier + '&pseudo=' + pseudo;
                document.getElementById('inputNouveau').className='cache';
                }
                }
                
                //Init "flash" object
                function InitFlashObj(){
                	if(document.embeds && document.embeds.length>=1 && navigator.userAgent.indexOf("Safari") == -1)
                		Flash = document.getElementById("EmbedFlashFilesUpload");
                	else
                		Flash = document.getElementById("FlashFilesUpload");
                }
                
                function submitClassicForm(){
                	document.form.submit();
                }
                
                function clearListBox(lstBox){		
                	while (lstBox.length > 0){
                		lstBox.remove(0);
                	}
                }
                
                function retabliBoutonEnvoyer(){
                	document.getElementById("flashInfoButtonSubmit").disabled = false;
                }
                
                function effacerListeFichiers(){
                	clearListBox(fileslist);
                	Flash.removeAll();
                	retabliBoutonEnvoyer();
                }
                
                /*
                MultiPowUpload_onMovieLoad. Invoked when the movie loaded and if browsers supports ExternalInterface i.e 
                programming interface that enables straightforward communication between Flash Movie and JavaScript.
                */
                function MultiPowUpload_onMovieLoad(){
                	InitFlashObj(); //sometimes Flash not initialized while window.onload event
                	Flash.width = 1;
                	Flash.height = 1;
                	
                	var JSUpload = document.getElementById("JSUpload");
                	JSUpload.style.visibility = "visible";
                	//JSUpload.style.width = 600;
                	JSUpload.style.height = 260;
                }
                    
                /*
                flash.browseFiles(typelist) displays a file-browsing dialog box in which the user can select a local file to upload. 
                The dialog box is native to the user's operating system.
                typelist - An array of file types used to filter the files displayed in the dialog box.
                */
                function browsefiles(){
                	var allTypes = new Array();
                	var imageTypes = new Object();
                	imageTypes.description = "Envoi de documents (<?php echo $extautoriseeStr ?>)";
                	imageTypes.extension = "<?php echo $extautoriseeStr ?>";
                	allTypes.push(imageTypes);    
                	/*
                	imageTypes = new Object();
                	imageTypes.description = "Images (*.JPG;*.JPEG;*.JPE;*.GIF;*.PNG;)";
                	imageTypes.extension = "*.jpg; *.jpeg; *.jpe; *.gif; *.png;";
                	allTypes.push(imageTypes);
                	*/
                	Flash.browseFiles(allTypes);
                }
                
                //Update HTML progress bar state
                function updateProgressBar(percentDone){
                	var rowProgress = document.getElementById("rowProgress");
                	if(percentDone>=1)
                		rowProgress.width = percentDone + "%";
                	else
                		rowProgress.width = "1";
                }
                
                /*
                flash.uploadAll(url) Starts the upload of a files in list to a remote server.
                url - The URL of the server script configured to handle upload through HTTP POST calls.
                */
                function upload(){
                	updateProgressBar(0);
                	uploadedfilescount = 0;
                	document.getElementById("lable").innerHTML = "";
                	//Flash.uploadAll(uploadUrl);
                	Flash.uploadAll(myUploadUrl);
                }
                
                //MultiPowUpload_onSelect. Invoked when the user selects a file to upload or download from the file-browsing dialog box.
                function MultiPowUpload_onSelect(){
                	var list = Flash.fileList();
                	var fileslist = document.getElementById("fileslist");
                	var i = 0;
                	clearListBox(fileslist);
                	for(i=0; i<list.length; i++){
                		fileslist.options[fileslist.options.length] = new Option(list[i].name, i, false, false );
                	}
                }
                    
                //MultiPowUpload_onProgress. Invoked periodically during the file upload or download operation
                function MultiPowUpload_onProgress(type, index, fileBytesLoaded, fileBytesLength, totalBytesLoaded, totalBytesLength) {
                	var PercentDone = new Number((totalBytesLoaded/totalBytesLength)*100).toFixed(1);
                	document.getElementById("lable").innerHTML = PercentDone + "% envoy&eacute;" + " - " + uploadedfilescount + " fichier(s)";
                	updateProgressBar(PercentDone);
                }
                    
                //MultiPowUpload_onError. Invoked when an input/output error occurs or when an upload/download fails because of an HTTP error
                function MultiPowUpload_onError(type, index, error) {
                	//window.alert("Fonction MultiPowUpload_onError(type, index, error)\ntype : "+type+"\nindex : "+index+"\nerror : "+error);
                	window.alert("Erreur en upload multiple (indisponibilité passagère ou incompatibilité de votre navigateur)\nUtilisez le formulaire d'envoi classique qui va s'afficher.");
                	setTimeout("effacerListeFichiers();",500);
                	setTimeout("ShowClassicUpload();",1000);
                }
                
                //MultiPowUpload_onComplete. Invoked when the upload or download of single file operation has successfully completed
                function MultiPowUpload_onComplete(type, index) {
                	uploadedfilescount++;
                }
                
                //MultiPowUpload_onCompleteAbsolute. Invoked when the upload or download of all files operation has successfully completed
                function MultiPowUpload_onCompleteAbsolute(type, totalBytesLoaded) {
                	document.getElementById("lable").innerHTML = "Envoi termin&eacute; - " + uploadedfilescount + " fichier(s)";
                	var fileslist = document.getElementById("fileslist");
                	clearListBox(fileslist);
                	setTimeout("updateUploadedFilesDiv();",500);
                }
                </script>
                <!-- // VUE DES FICHIERS ENVOYES -->
                <script type="text/javascript" src="openrico/rico.js"></script>
                <script language="JavaScript">
                // VUE DES FICHIERS ENVOYES
                
                </script>
                </td>
                <td class="md"></td>
                </tr>
                <tr><td class="bg"></td><td class="bc"></td><td class="bd"></td></tr>
                </table>
                </div>
                </div>
                   <div id="bas_de_page">
                   <?php include("bas_de_page.php");?>
                   </div>
                  
                </body>
                </html>
                <?php
                }
                else
                include("prive.php");
                ?>
                
                </body>
                </html>
                


                Toute la partie JS je l'ai prise toute faite sauf la petite fonction qui fait apparaitre un input que j'ai faite moi même ^^
                • Partager sur Facebook
                • Partager sur Twitter
                  4 novembre 2008 à 11:56:41

                  deja essaye de remplacer
                  <script language="javascript"> par <script type="text/javascript">
                  et refait tes test
                  • Partager sur Facebook
                  • Partager sur Twitter
                    4 novembre 2008 à 12:02:06

                    J'ai testé ça ne marche pas non plus :(
                    • Partager sur Facebook
                    • Partager sur Twitter

                    Probleme d'input

                    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                    • Editeur
                    • Markdown