上传图像并创建zip文件不起作用

时间:2013-04-08 15:52:42

标签: php mysql zip

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


?>

1 个答案:

答案 0 :(得分:0)

请参阅以下链接以获取zip文件

http://creativedev.in/2012/04/create-a-zip-file-in-php/

希望有所帮助