我正在制作一个简单的上传脚本。问题是,当我上传图像文件时,它很容易上传到服务器上,其数据写在我的数据库中,但当我尝试上传像mp4和音频mp3文件这样的视频文件时,服务器给我这个错误。
http://i.stack.imgur.com/FCq2c.png
这是我的upload.php代码。
<?php
include('config.php');
function bytesToSize1024($bytes, $precision = 2) {
$unit = array('B','KB','MB');
return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision).' '.$unit[$i];
}
$FileName = $_FILES['filename']['name'];
$FileType = $_FILES['filename']['type'];
$FileSize = bytesToSize1024($_FILES['filename']['size'], 1);
$Fileid = uniqid(rand());
$query2 = "INSERT INTO files (id, name, size, type) VALUES ('$Fileid', '$FileName', '$FileSize '$FileType')";
$result2 = mysql_query($query2);
echo <<<EOF
<p>Your file: {$FileName} has been successfully received.</p>
<p>Type: {$FileType}</p>
<p>Size: {$FileSize}</p>
EOF;
这是我的index.html代码
<form action="upload.php" method="post" enctype="multipart/form-data">
<center><p> <input type='file' size='58' style='height: 30px; font-size: 18px' name='filename'></p>
<input type="submit" name="submit" value="Upload">
</form>