找到你要的答案

Q:php cURL return page with error 500 on 000webhost

Q:PHP CURL返回页面错误500在000webhost

My page is host at 000webhost.com following is the scipt running curl:

$ch = curl_init($u);
$fp = fopen("u.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);

When I open the u.txt on my server, it has the following 500 error message:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 Server Error</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /p. Reason:
<pre>    Server Error</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>                                      
</body>
</html>

I ran the phpinfo(); on the server and cURL is enable.

My page is host at 000webhost.com following is the scipt running curl:

$ch = curl_init($u);
$fp = fopen("u.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);

当我打开u.txt我的服务器上,它具有以下500个错误消息:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 Server Error</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /p. Reason:
<pre>    Server Error</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>                                      
</body>
</html>

我跑phpinfo();在服务器和卷发使。

answer1: 回答1:

the goal was to download a large html file, the issue has been fixed using following code also found somewhere on stackoverflow:

function download($file_source, $file_target) {
$rh = fopen($file_source, 'rb');
$wh = fopen($file_target, 'w+b');
if (!$rh || !$wh) {
    return false;
}

while (!feof($rh)) {
    if (fwrite($wh, fread($rh, 4096)) === FALSE) {
        return false;
    }
    echo ' ';
    flush();
}

fclose($rh);
fclose($wh);

return true;
}

目标是要下载一个大的HTML文件,该问题已被固定使用下面的代码也发现计算器上的某处:

function download($file_source, $file_target) {
$rh = fopen($file_source, 'rb');
$wh = fopen($file_target, 'w+b');
if (!$rh || !$wh) {
    return false;
}

while (!feof($rh)) {
    if (fwrite($wh, fread($rh, 4096)) === FALSE) {
        return false;
    }
    echo ' ';
    flush();
}

fclose($rh);
fclose($wh);

return true;
}
answer2: 回答2:

Your webpage is being run by Jetty - i.e. your PHP code is not actually running. Stop or uninstall Jetty and then try again.


Powered by Jetty://

Your webpage is being run by Jetty - i.e. your PHP code is not actually running. Stop or uninstall Jetty and then try again.


Powered by Jetty://
php  curl