- 论坛徽章:
- 18
|
大家好!
我有一个问题向大家请教。
我的服务器在公司防火墙之内,需要通过http代理上网,所以我在原来可以正常执行的php程序中加了curl实现通过http代理上网的代码。
但是发现并不能正常执行。请大家帮我看看错在哪里呢?- <?php
- header("Content-Type: text/html; charset=UTF-8");
- date_default_timezone_set('PRC');
- $cweekday = array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
- $now = getdate(time());
- $cur_wday=$now['wday'];
- $cur_mon=$now['mon'] - 1;
- $cntime = date("现在时刻:Y年n月j日$cweekday[$cur_wday],G点i分。");
- echo $cntime;
- $newfname = './tmp/now.wmv';
- $creqBaseURL = 'http://translate.google.cn/translate_tts?ie=UTF-8&q=' . $cntime . '&tl=zh-CN';
- //这里开始是新加的内容。
- $ch = curl_init();
- $timeout = 5;
- curl_setopt($ch, CURLOPT_URL, $creqBaseURL);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_PROXY, "sg.proxy.alcatel-lucent.com");
- curl_setopt($ch, CURLOPT_PROXYPORT, 8000);
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, "username:password");
- curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- $file_contents = curl_exec($ch);
- //这里结束是新加的内容
- $cremote_file = fopen($file_contents, "rb"); //原来这句是$cremote_file = fopen($creqBaseURL, "rb");
- $newf = fopen($newfname, "wb");
- if ($newf){
- while(!feof($cremote_file)){
- fwrite($newf, fread($cremote_file, 1024 * 8),1024 * 8);
- }
- fclose($newf);
- }
- fclose($cremote_file);
- curl_close($ch);
- echo '<embed loop="1" autostart="true" hidden="true" src=./tmp/now.wmv />';
- ?>
复制代码 php报的错是:[Mon Jul 20 14:42:48 2015] [error] [client 192.11.236.118] PHP Warning: fopen(): Filename cannot be empty in /var/www/html/1.php on line 34
为什么会出这个错呢?
请指教。
谢谢大家! |
|