Bonjour,
je cherche une solution pour avoir l'info avant le téléchargement du fichier distant pour le comparer avec celui déjà présent.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 for ($i = 1; $i < 2; $i++) { $fp = fopen($path[$i], 'w'); $ch = curl_init($url[$i]); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); $curl_errno = curl_errno($ch); $curl_error = curl_error($ch); curl_close($ch); fclose($fp); $archive[$i] = new PclZip($path[$i]); if ($archive[$i]->extract(PCLZIP_OPT_PATH, $dir[$i], PCLZIP_OPT_REMOVE_PATH, 'install/release') == 0) { die("Error : ".$archive[$i]->errorInfo(true)); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 $message = ""; curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); $bytes = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); $message .= $dir[$i]." ".byte_convert($bytes)."</br>";
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 function byte_convert($bytes) { $symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $exp = 0; $converted_value = 0; if( $bytes > 0 ) { $exp = floor( log($bytes)/log(1024) ); $converted_value = ( $bytes/pow(1024,floor($exp)) ); } return sprintf( '%.2f '.$symbol[$exp], $converted_value ); }
Partager