上传.mp3和图片文件;差异b / w两者

时间:2011-12-22 14:05:42

标签: php image audio file-upload

这是我的剧本。:

<html>
<body>
<?php
if(isset($_POST['submit']))
{
 echo $_FILES['upload']['tmp_name']/['name']/['error']/['type'];
 // i.e. echoing all the temproray file location; name error status and type of file.
}
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?> method="post" />
<input type="hidden" name="MAX_FILE_SIZE" value="SOME_VALUE" />
<input type="file" name="upload" id="upload" />
<input type="submit" name="submit" />
</body>
</html>

现在这里有问题;基本上我希望用户在网站上传音乐;但是当我尝试使用某个.mp3文件测试此代码时,我遇到了以下麻烦。

  1. 任何大小超过8MB(我猜)的文件都没有进入代码的isset($_POST['submit'])条件。不知道为什么。

  2. 现在当我上传较小尺寸的文件时,我得到以下输出

    tmp_name:没事 name:显示文件名 错误:1(即文件未上传??) 类型:没什么

  3. 3现在当我上传.jpeg文件时,我得到了所有想要的结果。即。

    tmp_name   : Windows/temp/ BLAH...
    name       : name of file
    error      : 0 (i.e. successful upload)
    type       : jpeg
    

    为什么会这样?

    还有更好的方法来拉动用户上传音频文件吗?

1 个答案:

答案 0 :(得分:2)

我认为你应该检查你的php.ini settings

这些设置将决定您可以上传的最大文件大小: