Php 如何在mysql数据库中从服务器读取和上传文本文件

Php 如何在mysql数据库中从服务器读取和上传文本文件,php,mysql,Php,Mysql,我在WebHost服务器上有一个带有url的文本文件[ 我想读取第一个值直到分隔符,这是代码 <?php include 'dbconfig.php'; $file = fopen ("http://file_server.comxa.com/remote_server/temp.txt", "r"); if (!$file) { echo "<p>Unable to open remote file.\n"; exit; } while (!feof ($file)) { $

我在WebHost服务器上有一个带有url的文本文件[

我想读取第一个值直到分隔符,这是代码

<?php
include 'dbconfig.php';
$file = fopen ("http://file_server.comxa.com/remote_server/temp.txt", "r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
if (preg_match ("@\<title\>(.*)\</title\>@i", $line, $out)) {
    $title = $out[1];
    break;
}
$sql = "INSERT INTO `temprature` (`id`, `temprature`) VALUES (NULL, $line)";
$result = mysqli_query($conn,$sql) or die(mysqli_error($conn));
if($result)
{
    echo "temprature inserted";
}
else
{
    echo "failure";
}
}
fclose($file);  
?>

但此代码正在抛出错误

警告:福朋(http://file_server.comxa.com/remote_server/temp.txt):无法打开流:HTTP请求失败!在第3行的C:\xampp\htdocs\demo\server\u read.php中找不到HTTP/1.0 404
无法打开远程文件。

让我知道我错在哪里


注意:当我更改本地主机文件的路径时,它工作正常。尝试访问你的url。找不到删除服务器回复404。那么,当这个url从任何地方都无法访问时,为什么你希望在脚本中工作。实际上,我已将temp.txt上传到远程服务器目录中,但仍然无法读取它。问题既不是php,也不是with mysql。您似乎无法访问上载到主机的文件。请检查Web服务器是否具有此文件的读取访问权限。