异步:1. 发布网址和 2.图像下载(从给定的 URL)


Asynchronically: 1. Posting URL and 2. Image downloading (from the given URL)

我想知道如何异步下载图像。

使用:Codeigniter,JQuery。

背景:我们有一个网站,用户可以在其中发布URL。给定一个 URL,我们将: - 获取并提取 HTML 以提取 img 网址(使用 simple_html_dom( - 在我们的服务器(curl(中下载这些图像(如果有(。 - 发布用户完成的帖子。 - 将用户重定向到发布的帖子。

问题:下载图像可能需要一段时间,我们不想在那里阻止用户。

需要:有一种方法可以发布线程并允许用户在我们异步下载图像时正常导航,因为我们不需要图像出现在帖子中。

谢谢

在你的 PHP 脚本上,ignore_user_abort

ignore_user_abort(TRUE);
// just to be safe, override the default php timeout so the script doesn't timeout for long operations
ini_set('max_execution_time', 600);
// download images

http://php.net/ignore_user_abort