我试图上传一张图片并用这张图片创建一个 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();*/
?>