gpt4 book ai didi

javascript - 本地存储中出现损坏的 PDF 文件错误

转载 作者:行者123 更新时间:2023-12-02 21:22:31 26 4
gpt4 key购买 nike

我在 Controller 中获取 PDF 文件 base64 字符串。当我将其保存到本地存储时,它显示损坏的 PDF(未解码)错误。我该如何解决这个问题?有人能猜出来吗?

base64 字符串:

"data:application/pdf;filename=generated.pdf;base64,JVBERi0xLjMKJbrfrOAKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAyIDAgUgovTWVkaWFCb3ggWzAgMCA1OTUuMjggODQxLjg5XQovQ29udGVudHMgNCAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL0xlbmd0aCA1NjMyCj4+CnN0cmVhbQowLjI3IHcKMCBHCnEKMC43OCBnCjIuNjcgODI1Ljg5IDI2LjUzIC04OS44NyByZQpCCkJUCi9GMiAxNCBUZgoxNi4xMCBUTAowIGcKNi42NyA4MDQuNDIgVGQKKENpcmN1aXQpIFRqCkVUCjAuNzggZwoyOS4yMCA4MjUuODkgMjYuNTMgLTg5Ljg3IHJlCkIKQlQKL0YyIDE0IFRmCjE2LjEwIFRMCjAgZwozMy4yMCA4MDQuNDIgVGQKKFJhdGluZykgVGoKRVQKMC43OCBnCjU1LjczIDgyNS44OSAxNjkuMTMgLTg5Ljg3IHJlCkIKQlQKL0YyIDE0IFRmCjE2LjEwIFRMCjAgZwo1OS43MyA4MDQuNDIgVGQKKERlc2NyaXB0aW9uKSBUagpFVAowLjc4IGcKMjI0Ljg2IDgyNS44OSAyNi41MyAtODkuODcgcmUKQgpCVAovRjIgMTQgVGYKMTYuMTAgVEwKMCBnCjIyOC44NiA4MDQuNDIgVGQKKENpcmN1aXQpIFRqCkVUCjAuNzggZwoyNTEuMzkgODI1Ljg5IDI2LjUzIC04OS44NyByZQpCCkJUCi9GMiAxNCBUZgoxNi4xMCBUTAowIGcKMjU1LjM5IDgwNC40MiBUZAooUmF0aW5nKSBUagpFVAowL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QjI4MzcyN0U1PiBdCj4+CnN0YXJ0eHJlZgo4MDYzCiUlRU9G"
 $pdf = $request->get('pdf_file');
$id = $request->get('user_id');
$data = explode( ',', $pdf);
$file_name = time() . '-test.pdf';
$path = public_path() . '/images/users/' . $file_name;

file_put_contents($path, $data[1]);

最佳答案

请尝试这个更新解决方案,这绝对适合您。

$pdf = $request->get('pdf_file');
$id = $request->get('user_id');

$data = explode( ',', $pdf);

# Decode the Base64 string, making sure that it contains only valid characters
$bin = base64_decode($data[1], true);


$file_name = time() . '-test.pdf';
$path = public_path() . '/images/users/' . $file_name;


# Write the PDF contents to a local file
file_put_contents($path, $bin);

关于javascript - 本地存储中出现损坏的 PDF 文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60811211/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com