File "custom_multiple08.php"

Full Path: /home/analogde/www/Prog/File explorer/custom_multiple08.php
File size: 8.46 KB
MIME-type: text/html
Charset: utf-8

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<?php

    //session_start();
    //echo "<pre>";
	//print_r($_SESSION);
	//echo "</pre>";
    //echo $_SESSION["argument"];
    //echo "<br><br>"; 
    //echo $_SESSION["path"]; 
    
    if (isset($_GET['p'])) 
    {
        //echo $_GET['p'];
        //echo "<br><br>"; 

        //***
        $pieces = explode("***", $_GET['p']);

        //print_r($pieces);

        //echo $pieces[0]; 
        //echo "<br><br>"; 
        echo $pieces[1]; 
        echo "<br><br>"; 
        //echo substr($pieces[1],2);
        //echo "<br><br><br>";
        //$arg = substr($pieces[1],2);

        //echo " ----- " .$_GET['p'] ."  " .$pieces[1];

        if(empty($pieces[1])) 
        {
            $upload_location = "/home/analogde/www/";
        }
        else
        {
            $upload_location = "/home/analogde/www/" .$pieces[1]  ."/";
        }

        echo " Répertoire target : " .$upload_location ."<br>";

        setcookie("cookie_upload",  $upload_location , time()+3600);

    }

?>

	<script src=  "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 

<!--
https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.3/themes/blitzer/jquery-ui.min.css
-->
<!--
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.3/themes/blitzer/jquery-ui.min.css">

<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css">  a voir !!!
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
-->

<!--   OK -->
<!--<link rel="stylesheet" href= "https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/dark-hive/jquery-ui.css"> -->
<link rel="stylesheet" href= "https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css"> 
<script src= "https://code.jquery.com/jquery-2.1.3.js"></script> 
<script src= "https://code.jquery.com/ui/1.11.2/jquery-ui.js"></script> 
<!--      -->

<script> 
   /* $(document).ready(function() { 
        $("#demoDialog").dialog(); 
    }); */

function redirection()
{
    setTimeout(function()
    { 
     //window.location.href = "https://www.example.com";
     window.history.go(-1);
    }, 5000);
}

</script> 

<script>

var resultat = [];
            
$(document).ready(function(){

    $('#submit').click(function(){

            var form_data = new FormData();

            // Read selected files
            var totalfiles = document.getElementById('files').files.length;

            if( totalfiles == 0)
            {
                $("#demoDialog").dialog( {
                    resizable: false,
                    width: 250,
	                height: 175,
                    modal: true,
		overlay: {
			opacity: 0.5,
			background: "black"
		}

                } 


                 ); 
                //alert("Error !");
                
									/*$( "#message_expiration" ).dialog({
									modal: true,
									title: "Infos",
									buttons: {
												Ok: function()
												{
													$( this ).dialog( "close" );
													
												}
											 }
										});*/
							
            }

            else
            {
                    for (var index = 0; index < totalfiles; index++) 
                    {
                        form_data.append("files[]", document.getElementById('files').files[index]);
                    }

                    // AJAX request envoi_multiples07.php   debug_upload01.php
                    $.ajax({
                        url: 'upload_fichier01.php', 
                        type: 'post',
                        data: form_data,
                        dataType: 'json',
                        contentType: false,
                        processData: false,

                        beforeSend: function()
                                {
                                    $("#loader").show();
                                    
                                }, 

                        success: function (response) {

                                for(var index = 0; index < response.length; index++)
                                {
                                    var src = response[index];
                                   
                                    
                                    console.log(" ----- TEMP -------" + response[index]);
                                    resultat.push(response[index]);

                                    // Add img element in <div id='preview'>
                                    //$('#preview').append('<img src="'+src+'" width="200px;" height="200px">');
                                }

                        },

                        complete: function (data) 
                        {
                                    console.log(" ----- FIN -------" + resultat + " " + data);

                                   // alert(JSON.stringify(data));

                                    $("#loader").hide();
                                    $('#user_reponse').html( " plouf Yes !" );

                                    var html = "<table>";
                                    for( var i=0; i < resultat.length ; i++ )
                                    {

                                        var text = resultat[i]; //  + " : envoi réussi ..........."    

                                        html += "<tr>";
                                        html += "<td>" + text + "</td>";

                                        //alert(text);   
                                        
                                        let position = text.search("Erreur");

                                        if( position >= 0)
                                        {
                                            html += "<td><img src='no.png' alt='Image' width='32' height='32'></td>";
                                        }   
                                        else
                                        {
                                            html += "<td><img src='yes.png' alt='Image' width='32' height='32'></td>";
                                        } 

                                         

                                        //html += "<tr>";
                                        //html += "<td>" + text + "</td>";
                                        //html += "<td><img src='check.png' alt='Image' width='32' height='32'></td>";
                                        //html += "</tr>";

                                    } 
                                    html += "</table>";   

                                    //var html = resultat;
                                    document.getElementById("resultat").innerHTML = html;

                                    document.getElementById("message_redirection").innerHTML = "Vous allez être rediriger ...";

                                    //redirection();
                                    
                            }

                    });
            }
    });

});

</script>

<form method='post' action='' enctype="multipart/form-data">
    <input type="file" id='files' name="files[]" multiple><br>
    <input type="button" id="submit" value='Upload'>
</form>

<!--
<a href="javascript:history.go(-1)" title="Return to the previous page">Retour</a>
-->

<form>
 <input type="button" value="Retour" onclick="history.go(-1)">
</form>

<!--
<div id="preview"></div>
-->

<!-- Image loader -->
<div id="loader" style="display: none;">
<img src="wait.gif" alt="Envoie ..." width="50" height="60">
</div>

<p id="user_reponse"></p>

<div id="dialog" title="Basic dialog"  style="display:none">
    <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
  </div>

  <div id="message_expiration" style="display: none">
    <p>
    <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
    La session a expiré. veuillez vous reconnecter.
    </p>
    </div>  

    <div id="demoDialog" title="Message" style="display:none"> 
        <p>Aucun fichier selectionné.</p> 
    </div> 

    <p id="resultat"></p>

    <br><br>

    <p id="message_redirection"></p>