Created
February 1, 2016 05:21
-
-
Save ferdhika31/29aa4e757e338c30c530 to your computer and use it in GitHub Desktop.
Nyolong gambar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Nanya awal nim na. | |
echo "MASUKKAN NIM\nContoh 1515240 (JTK D4)\nMasukkan :"; | |
$ngambilNim = fgets(fopen ("php://stdin","r")); // ngambil inputan nim | |
// Nyimpen gambarna dimana? | |
//echo "Masukkan folder tujuan :"; | |
//$targetFolder = fgets(fopen ("php://stdin","r")); // ngambil inputan nim | |
echo "Mau ngambil absen 1 sampe berapa? "; | |
$nginput = fopen ("php://stdin","r"); // nginput dari keyboard | |
$baris = fgets($nginput); // ngambil inputan | |
for($i=1;$i<=$baris;$i++){ | |
if($i<10){ | |
$i="0".$i; | |
} | |
//echo substr($ngambilNim,0,7).$i."\n"; | |
nyimpen(substr($ngambilNim,0,7).$i); | |
} | |
// Anonymous function | |
function nyimpen($nim){ | |
/* Url dari server */ | |
$url = "http://akademik.polban.ac.id/foto/".$nim.'.JPG'; | |
/* File baru di simpen ke lokal in */ | |
$ngaran = $nim.'.jpg'; | |
/* Nyalin file ti server liwat url */ | |
$copy = copy($url, $ngaran); | |
/* Status */ | |
if(!$copy ) { | |
echo "Pirakuu! gagal \n"; | |
} | |
else{ | |
echo "Mantap jiwaaa! $nim.jpg sukses disimpen kawan\n"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment