文件获取内容(#)无法打开流HTTP请求失败

时间:2015-06-10 07:56:24

标签: php laravel-4

foreach($users as $user){

                            $url = web_url()."/user/invoice/generate?id=".$user->user_id."&month=".$month."&year=".$year;
                            $html = file_get_contents($url);
                            $file= public_path(). "/invoice/".$user->user_id."_".$month."_".$year.".pdf";
                            $headers = array(
                                'Content-Type' => 'application/pdf',
                            );
                            return Response::download($result, $user->user_id."_".$month."_".$year.".pdf", $headers);
                }

使用上面的代码,我试图为许多用户下载发票。但它抛出文件获取内容(#)无法打开流HTTP请求失败错误。我也试过" Curl"使用下面的代码,它也会抛出相同的错误。

foreach($users as $user){

                            $url = web_url()."/user/invoice/generate?id=".$user->user_id."&month=".$month."&year=".$year;

                                $curl = curl_init();
                              curl_setopt($curl, CURLOPT_URL, $url);
                              curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                              curl_setopt($curl, CURLOPT_HEADER, false);
                              $data = curl_exec($curl);
                              curl_close($curl);

                            $file= public_path(). "/invoice/".$user->user_id."_".$month."_".$year.".pdf";
                            $headers = array(
                                'Content-Type' => 'application/pdf',
                            );
                            return Response::download($result, $user->user_id."_".$month."_".$year.".pdf", $headers);
                }       

有人能建议我下载许多发票的正确有效方法吗?

0 个答案:

没有答案