如何使用数据库中存在的文件进行压缩下载?

发布于 2024-11-09 08:42:02 字数 875 浏览 0 评论 0原文

我想为我的用户制作某种用户面板 - 在他们更新面板上的信息后,它将在数据库中为他们创建一个新行,其中包含我构建的原始源代码,但包含他们编辑的字段。

示例:

用户名:[_______]

页面 ID:[_______]

他们填写它,当他们按下更新时,它会自动将数据插入到表中新字段的预制代码中。

<?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.

I want to make some kind of user panel for my users - after they will update the info on the panel it will make a new row for them in the database with an original source code which i build but with the edited fields they made.

Example:

UserName: [_______]

PageID: [_______]

They fill it in and the when they press update it will automatically insert the data to a pre-made code to a new field in the table.

<?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?)
?>

Now that was the first question: whats the best way to insert UserName textarea value in here?

The Second question is how to Auto Encrypt this on insert (I don't care about the way it will be encrypted, even if it will not be IonCube encrypted it will be fine)

And the last and the most important question is how to make an automatic function that when they will press "Update" will automatically make files from the SQL field and prompt them to download the zipped files with their files (I don't want to store any of those files on my server because they may interrupt one with the other cause there may be 100 users doing this action at the same time)

Guys trust me i has been looking for this answers all over the net and didn't found a thing.. (I found EVERYTHING i need except this stuff).

Thanks for future assistance guys!

Best Regards, Rico S.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨夜星沙 2024-11-16 08:42:02

1)最好的方法是使用某种格式,例如
像这样放你的模板
$template = "在此处插入 %%UserName%% %%textarea%% 值的最佳方式是什么。";

然后使用

$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 的标志。如果它不起作用,那么也一样。在这种情况下,请告诉我,并提供您的代码,我也许可以帮助您。截至目前,我还没有尝试过。

1) The best way to do it is by using some sort of formatting like
Put you template like this
$template = "whats the best way to insert %%UserName%% %%textarea%% value in here.";

And then create an array with like

$trans = array ("%%UserName%%" => $username, "%%textarea%% => $textarea);

Then use php's strtr function to convert it

$data_to_store = strtr($template, $trans);

2) You can find a lot of encryption and decryption algorithms and php classes for doing that check out PHP Classes.

3) You could try this. But i am not 100% sure if its works properly.
Use PHP's ZipArchive Directory
And then load the content's into a string
then

<?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;

?>

I hope this works, If it didn't try changing the flags of ZipArchive::open. And if it didn't work then also. In that case let me know, with you code and i might be able to help you. As of this point, i havn't tried it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文