为啥我上传的视频出现“文件扩展名和文件格式不匹配无法播放”的提示啊
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为啥我上传的视频出现“文件扩展名和文件格式不匹配无法播放”的提示啊相关的知识,希望对你有一定的参考价值。
WMV的AVI的最常见的视频格式啊。
如需要下载编码器,解码器之类的,望详细说明其原理及步骤。十分感谢
视频处理好后,我设置的扩展名和格式是一样的, 在上传前还需要用其他软件进行别的处理么?
我是往网站上,上传视频,传上去了,不能播放
参考技术A 网络上是FLV多上些为啥我用这段php上传代码总是出现这个问题?
用的是下面的php代码:
<html>
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="file.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
</html>
//file.php
<?php
$uploaddir = './var/';
echo $uploaddir ;
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo $uploadfile;
echo '<br>Come in <br>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
echo "File is valid, and was successfully uploaded.\n";
else
echo "Possible file upload attack!\n";
echo 'Here is some more debugging info:';
print_r($_FILES);
?>
但是上传后总是出现
/bt//bt/bb_qvod.png
Come in
Warning: move_uploaded_file(/bt/bb_qvod.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/ipower/public_html/bt/upload.php on line 12
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpZkTgsp' to '/bt/bb_qvod.png' in /home/ipower/public_html/bt/upload.php on line 12
Possible file upload attack! Here is some more debugging info:Array ( [userfile] => Array ( [name] => bb_qvod.png [type] => image/png [tmp_name] => /tmp/phpZkTgsp [error] => 0 [size] => 1050 ) )
还有如何控制上面的文件上传类型
$uploaddir = './var/';
这一行代码和你显示出来的不一样。
你用的应该是虎翼网的空间吧。。如果你要上传到 bt 目录。直接这么写就可以了。
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name'])) 参考技术B 给你个我写的上传类自已去看看吧
class upload
private $uploadFile; //上传路径
private $uploadType; //数组上传文件类型
private $uploadSize; //上传文件大小
public function __construct($uploadFile , $uploadType , $uploadSize)
$this->uploadFile = $uploadFile;
$this->uploadType = $uploadType;
$this->uploadSize = $uploadSize;
public function is_upload($name)
$error = new error();
if(!is_uploaded_file($_FILES[$name][tmp_name]))
return $error->alert_msg("文件上传不成功,请重新上传" , 1);
return true;
public function is_uploadSize($name)
$error = new error();
if($_FILES[$name]['size'] > $this->uploadSize)
echo $this->uploadSize;
return $error->alert_msg("文件太大了,请压缩后重新上传" , 1);
return true;
public function is_uploadType($name)
$fileType = explode( "." , $_FILES[$name]['name'] );
$count = (count($fileType) - 1);
$type = $fileType[$count];
for($i=0;$i<count($this->uploadType);$i++)
$retType .= $this->uploadType[$i].",";
$setType = trim($retType , ",");
$error = new error();
if(!in_array( $type , $this->uploadType ))
return $error->alert_msg("上传文件类型错误,只能上传".$setType."类型的文件,请重新上传" , 1);
return true;
public function uploading ($name)
$error = new error();
if($this->is_upload($name) && $this->is_uploadSize($name) && $this->is_uploadType($name))
if(!file_exists($this->uploadFile))
mkdir($this->uploadFile , 0777) or die("无法创建目录");
$fileName = date("Y-m-j" , time())."-".$_FILES[$name]['name'];
if(!file_exists($this->uploadFile."/".$fileName))
if(!move_uploaded_file ($_FILES[$name]['tmp_name'], $this->uploadFile."/".$fileName))
return $error->alert_msg("文件无法移动,请检查设置" , 1);
else
return $error->alert_msg("上传文件已存在,请重新上传" , 1);
return true;
参考技术C $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
去掉basename即可
最好是加个是否上传成功的判断本回答被提问者采纳 参考技术D if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
你这句是怎么移动的 没给文件名好么!!!! 第5个回答 2008-06-09 <form action="xxx.php" method="post" enctype="multipart/form-data">
少了这句吧enctype="multipart/form-data"
以上是关于为啥我上传的视频出现“文件扩展名和文件格式不匹配无法播放”的提示啊的主要内容,如果未能解决你的问题,请参考以下文章
上传视频文件成功后$_FILES['name']的值为啥是blob?而不是原始文件名?怎么才能获取到原始文件名?
为啥经常看到有人上传一些3D动漫人物的舞蹈视频?下载地址能发我一下吗