PHP文件上传保持时间安排

时间:2012-08-09 22:19:13

标签: php file upload timeout

我有一个问题,我正在尝试使用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文件正在被正确读取。 有没有什么办法解决这一问题?任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:0)

忽略uploader.php文件中的HTML注释。他们不应该在那里。

答案 1 :(得分:0)

好的我明白了。我的webhost不允许我上传大于5MB的文件...这有点糟糕但我想我会使用外部托管。