我正在创建一个将 mp3 文件存储在数据库中的站点。当我访问该站点时,它说我已成功连接到数据库并且我已成功选择数据库。但是当我选择一个文件并按下上传按钮时,它会尝试连接很长时间,然后我的网络浏览器才会显示“页面加载时与服务器的连接已重置”注释掉的代码不起作用. 编辑:我使用托管服务可能是相关的。
<!DOCTYPE html>
<!-- HTML5 style -->
<html lan="en">
<head>
<title>Upload Music</title>
<meta charset="utf-8" />
</head>
<body>
<form action="UploadMusic.php" method="POST" enctype="multipart/form-data">
File:
<input type="file" name="music"/> <input type="submit" value="Upload"/>
</form>
<?php
$DBConnect = mysql_connect("replaced", "for", "privacy");
if ($DBConnect === FALSE) {
echo "Did not successfully connect to the database server." .
"<p>Error code " . mysql_errno()
. ": " . mysql_error() . "</p>";
}
else {
echo "<p>Successfully connected to the database server</p>";
if (mysql_select_db("replaced") === FALSE) {
echo "Did not successfully select the database";
}
else {
echo "Successfully selected the database";
/*$file = $_FILES["music"]["tmp_name"];
echo $file;
if (!isset($file)) {
echo "Please select a mp3 file to upload";
}
else {
$music = file_get_contents($_FILES["music"]["tmp_name"]);
echo $music;
}
*/
}
}
?>
</body>
</html>