[英]How to make a zipped download with files that exist in a database?
我想为我的用户创建某种用户面板-在他们更新面板上的信息之后,它将使用我构建的原始源代码以及他们进行的编辑后的字段在数据库中为他们创建新行。
例:
用户名:[ _ __ _ ___]
PageID:[ _ __ _ ___]
他们将其填充,并在按下update时将数据自动插入到预先创建的代码中,并将其插入表中的新字段。
<?php
$username = ? (whats the best way to insert UserName textarea value in here?)
$pageid = ? (whats the best way to insert UserName textarea value in here?)
?>
现在是第一个问题:在此处插入UserName textarea值的最佳方法是什么?
第二个问题是如何在插入时自动对其进行加密(我不在乎它会被加密的方式,即使它不会被IonCube加密也可以)。
最后一个也是最重要的问题是如何创建自动功能,使其在按下“更新”时将自动从SQL字段中创建文件,并提示他们将压缩文件与文件一起下载(我不想存储我服务器上的这些文件中的任何一个,因为它们可能会互相干扰,可能是因为有100个用户同时执行此操作)
伙计们相信我,我一直在网上寻找这个答案,却没有发现任何东西。(我发现除了这个东西我需要的一切)。
多谢您日后的协助!
最好的问候,Rico S.
1)最好的方法是使用某种格式,例如使用$template = "whats the best way to insert %%UserName%% %%textarea%% value in here.";
这样的$template = "whats the best way to insert %%UserName%% %%textarea%% value in here.";
然后用like创建一个数组
$trans = array ("%%UserName%%" => $username, "%%textarea%% => $textarea);
然后使用php的strtr
函数将其转换
$data_to_store = strtr($template, $trans);
2)您可以找到许多加密和解密算法以及php类,以检查出PHP类 。
3)您可以尝试一下。 但是我不是100%确信它能否正常工作。 使用PHP的ZipArchive目录,然后将内容加载到字符串中,然后
<?php
header('Content-Disposition: attachment; filename="downloaded.pdf"');
$zip = new ZipArchive;
$res = $zip->open('php://stdout', ZipArchive::CREATE);
if ($res === TRUE) {
$zip->addFromString('file.txt', $content_populated_from_db);
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
exit;
?>
我希望这能奏效,如果不尝试更改ZipArchive::open
的标志。 如果它不起作用,那么也可以。 在这种情况下,请告诉我,有了您的代码,我也许可以为您提供帮助。 到目前为止,我还没有尝试过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.