我有一个问题,我试图使用 PHP 将 MP3 文件上传到我的网站。
几秒钟后连接/服务器超时。
这是 PHP 上传表单的 HTML 代码:
<html>
<head>
<title>Upload Music</title>
<link rel="stylesheet" type="text/css" href="css/styles.css" />
</head>
<br />
<div class="center">
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="200000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</div>
</html>
这是 uploader.php 文件:
<head>
<title>Success!</title>
<link rel="stylesheet" type="text/css" href="css/styles.css" />
</head>
<div class="center">
<br />
<?php
set_time_limit(1000000);
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file " . basename( $_FILES['uploadedfile']['name']) .
" has been uploaded";
} else {
echo "There was an error uploading the file, please try again!";
}
file_put_contents("uploads.txt", basename( $_FILES['uploadedfile']['name']),
FILE_APPEND);
?>
</div>
</html>
这是我的 php.ini 文件:
upload_max_filesize = 2000M
post_max_size = 2000M
memory_limit = 2000M
max_input_time = 1000000000
max_execution_time = 1000000000
我检查了 phpinfo() ,看起来我的 php.ini 文件被正确读取。有没有什么办法解决这一问题?任何帮助将不胜感激!