我试图上传图片并使用此图片创建一个zip文件,我在这里观看了任何代码,但我不太明白。求助。
PHP
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?
require('conecta.php');
$uploaddir = '/var/www/subirImagenBD/';
$fechaFoto=date('YmdHis').'_'.basename($_FILES['Foto']['name']);
if (is_uploaded_file($_FILES['Foto']['tmp_name'])) {
$uploadfile = $uploaddir . $fecha . $fechaFoto;
move_uploaded_file($_FILES['Foto']['tmp_name'], $uploadfile);
$cFoto=basename($_FILES['Foto']['name']);
}
echo $cFoto." guardada en ".$uploaddir. $fechaFoto."<br>";
$cSQL="INSERT INTO FOTOS (NOMBRE,PIC) VALUES (?,?)";
$stmt=$oConni->prepare($cSQL);
$stmt->bind_param("ss", $fechaFoto, file_get_contents($uploaddir. $fechaFoto));
$stmt->execute();
/*
$zipFile = $fechaFoto;
$zipArchive = new ZipArchive();
if (!$zipArchive->open($zipFile, ZIPARCHIVE::OVERWRITE))
die("Failed to create archive\n");
$zipArchive->addGlob($fechaFoto);
if (!$zipArchive->status == ZIPARCHIVE::ER_OK)
echo "Failed to write local files to zip\n";
$zipArchive->close();*/
?>