简体   繁体   English

即时创建和存储图像

[英]Create and store images on the fly

How would I go about catching a request for images that doesn't exist and create them as needed so as not to return a 404?我将如何 go 关于捕获对不存在的图像的请求并根据需要创建它们以免返回 404? These would then be stored on the server until no longer needed and deleted.然后这些将存储在服务器上,直到不再需要并被删除。 The code would preferably be in PHP.代码最好在 PHP 中。 Deletion will most likely occur in a cron job.删除很可能发生在 cron 作业中。

The images would be requested in batches of 10 or so at a time with names such as 084a007b0138024f0a.jpg.图像将一次请求 10 个左右的批次,名称为 084a007b0138024f0a.jpg。

Edit your htaccess, so in that folder requests for any image is redirected to a PHP script.编辑您的 htaccess,以便在该文件夹中对任何图像的请求都被重定向到 PHP 脚本。

Then, in your script, create the image ( http://php.net/image/ ) and simply echo it.然后,在您的脚本中,创建图像( http://php.net/image/ )并简单地显它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM