Projet

Général

Profil

Paste
Télécharger (6,02 ko) Statistiques
| Branche: | Révision:

root / envoyer.php @ 1f5db711

1
<?php $uid = md5(uniqid(rand())); ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
4
        <head>
5
            
6
            <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
7
            <link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/>
8
                  <link rel="stylesheet" media="screen" href="css/view.css" />
9
            <title>Upload d'une image sur le serveur !</title>
10
                    <!-- suivi de l'upload par ajax. Peut être utile pour certains navigateurs qui ne renseigne pas l'avancement.
11
                <script type="text/javascript">
12
                        var HttpRequestObject = false;
13
                        if(window.XMLHttpRequest) {
14
                           HttpRequestObject = new XMLHttpRequest();
15
                        }
16
                        else if(window.ActiveXObject) {
17
                           HttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
18
                        }
19
                        
20
                        function startProgress(uid) {
21
                          
22
                                
23
                           <!--document.getElementById('upload').style.display = 'none';-->
24
                           document.getElementById('pb_outer').style.display = 'block';
25
                           setTimeout('getProgress("' + uid + '")', 1000);
26
                          
27
                           
28
                           
29
                        }
30
                        function getProgress(uid) {
31
                           if(HttpRequestObject) {
32
                              HttpRequestObject.open('GET', 'getprogress.php?uid=' + uid, true);
33
                              HttpRequestObject.onreadystatechange = function() {
34
                                 if(HttpRequestObject.readyState == 4 && HttpRequestObject.status == 200) {
35
                                    var response = HttpRequestObject.responseText;
36
                                    var elem = response.split('#');
37
                                    var progress = elem[0];
38
                                    var url =elem[1];
39
                                    var message=elem[2];
40
                                    
41
                                    document.getElementById('pb_inner').style.width = progress + '%';
42
                                    document.getElementById('pb_inner').innerHTML = progress + '%';
43
                                   
44
                                    if(progress < 100) {
45
                                       
46
                                       setTimeout('getProgress("' + uid + '")', 100);
47
                                        
48
                                    } else {
49
                                            if(message !=='') {
50
                                                    document.getElementById('pb_outer').style.display = 'none';
51
                                                    document.getElementById('pb_inner').style.width = 'none';
52
                                                           alert(message);
53
                                            } else {
54
                                                    document.getElementById('pb_inner').innerHTML = 'Upload Complete!';
55
                                                    document.location.href= url; 
56
                                            }
57
                                    }
58
                                 }
59
                              }
60
                              
61
                              HttpRequestObject.send(null);
62
                           }
63
                        }
64
                        
65
                        function showLoader() {
66
                                document.getElementById('loader').innerHTML = "Veuillez patienter ...  ";
67
                                
68
                                
69
                        }
70
                        
71
                </script>
72
        </head>
73
        <body id="main_body">
74
                  <img id="top" src="images/top.png" alt="">
75
                <div id="form_container">
76
                        <h1><img src="images/tetaneutral.png"></h1>
77
                
78
                    <form onSubmit="startProgress('<?php echo $uid; ?>');" action="uploadTest.php" method="post" class="appnitro" enctype="multipart/form-data" name="upload" id="upload" target="upload_frame">
79
                                 <h2>Ajouter un nouveau panorama</h2>
80
                                                                                
81
                        <ul>
82
                                <li id="li_1" >
83
                                        <label for="file" class="description">Envoyer le fichier :</label>
84
                                        <div>
85
                                <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $uid; ?>" />
86
                                <input type="file" name="file" id="file" />
87
                                            </div>  
88
                                </li>
89
                                
90
                                <li class="buttons">
91
                                <input type="submit" name="submit" id="submit" value="Submit" />
92
                        </li>
93
                        </ul>
94
                        </form>
95
                        <!-- Fin du formulaire -->
96
                        <div id="footer">
97
                                <a href="./index.php">Retour liste</a>
98
                        </div>
99
                </div>
100
                <div id="infoSize">
101
                <img src="images/bulle.png" id="bulle"/>
102
                <label id="txtInfo">Le fichier à envoyer doit etre une image de type .tif ou .jpeg<br />
103
        Taille maximale : 300 Mo</label>
104
            </div>
105
                <!-- Barre d'upload -->
106
                <div id="pb_outer">
107
                  <div id="pb_inner"></div>
108
                  </div>
109
                  <p id="info"></p>
110
          
111
          <iframe style="display: none" id="upload_frame" name="upload_frame"></iframe>
112
         
113
    <?php 
114
    
115
    /*******************************************************************
116
     * Permet d'afficher l'image uploadée sur le serveur
117
     *******************************************************************/
118

    
119
    if(isset($_GET['img']) && isset($_GET['dir'])){
120
  
121
            apc_delete('link');   // Suppression de la variable cache.
122
            
123
            $image_name = htmlspecialchars($_GET['img']);
124
            $dir_image = htmlspecialchars($_GET['dir']);
125
            
126
        $basename = basename($_GET['img']);
127
            $filePartArr = explode('.', $basename);  
128
        $ext = $filePartArr[count($filePartArr) - 1];
129
        if($ext=="tif"){
130
                $basename = basename($_GET['img'],".tif");
131
        }else if($ext=="jpeg"){
132
              $basename = basename($_GET['img'],".jpeg");
133
               } else {
134
              $basename = basename($_GET['img'],".jpg");
135
        } 
136
                    //Permet d'afficher l'image après uptload ( Conversion des .tiff et .jpg pour affichage dans le navigateur )
137
                $input = 'convert /var/www/data/tsf2/vpongnian/panorama/upload/'.$_GET['img'].' -resize 10% /var/www/data/tsf2/vpongnian/panorama/upload/'.$basename.'.jpg'; // Adapter les chemins absolus ou relatifs
138
                $escaped_command = escapeshellcmd($input);
139
                $output = shell_exec($escaped_command);
140
                echo "<pre>$output</pre>\n";
141
                
142
    ?><div id="genererPano">
143
                <form enctype="multipart/form-data" action="<?php echo "envoyer.php"/*htmlspecialchars($_SERVER['PHP_SELF'])*/; ?>" method="post" onSubmit="showLoader()">
144
                  <p>
145
                    <label id="l_generer" for="no" title="Génerer le panoramique">Generer le panoramique :</label>
146
                    <input type="hidden" name="image_name" value="<?php echo $image_name; ?>" />
147
                    <input type="submit" name="no" value="pas maintenant"/>
148
                    <input type="submit" name="yes" value="oui" />
149
                    <label id="loader"></label>
150
                  </p>
151
                </form>
152
          </div>
153
    <?php 
154
   
155
    echo "<img src=/data/tsf2/vpongnian/panorama/upload/".$basename.".jpg id='imageUpload'/>";
156
    }  
157
    if (isset($_POST['no'])) {
158
                header("Location: ./index.php"); /* Redirection du navigateur */
159
                exit;
160
        } 
161
        if (isset($_POST['yes'])) {
162
                header("Location: ./genererPano.php?name=".$_POST['image_name']);
163
                exit;
164
        }
165
    ?>
166
   
167
  </body>
168
</html>