Screenshot automatisch aus ZIP-Datei erzeugen
Genauer gesagt: Screenshot im JPEG Format in die Zip-Datei packen und nach dem Upload automatisch entpacken.
PHP Code:
<?php
$default_ss = $_GET["def"]; //"default.png";
$zipfile = $_GET["zip"];
$ss_name = "screenshot.jpg"; // Screenshot name in zip archive
$zip_ss = $zipfile.".jpg"; // dirname($zipfile)."/".
if ($zipfile){
if (is_file($zipfile)){
if (is_file($zip_ss)){
header("Location: $zip_ss");
exit;
}
else {
$z_a = new ZipArchive();
if ($z_a->open(dirname(__FILE__) . "/".$zipfile)) {
if ($z_a->getFromName("$ss_name")){
$screenshotimg = $z_a->getFromName("$ss_name");
$im = imagecreatefromstring($screenshotimg);
Imagejpeg($im, $zip_ss, 90);
imagedestroy($im);
if (is_file("$zip_ss")){
header("Location: $zip_ss");
exit;
} else {print "screenshot failed!";}
}
else {
header("Location: $default_ss");
exit;}
}
}
}
else {
print "zip archive not found!";}
}
?>
Code in einer Datei, z.B. zip_ss.php, abspeichern.
HTML-Code:
<img src="/zip_ss.php?zip=meine_uploads/datei.zip&def=images/default.png">

Neueste Kommentare
vor 1 Tag 21 Stunden
vor 3 Tage 3 Stunden
vor 3 Tage 8 Stunden
vor 5 Tage 6 Stunden
vor 6 Tage 3 Stunden
vor 1 Woche 1 Tag
vor 1 Woche 1 Tag
vor 1 Woche 2 Tage
vor 1 Woche 2 Tage
vor 1 Woche 3 Tage