Home Backend Development PHP Tutorial php 视频、音频和图片文件上传,该如何解决

php 视频、音频和图片文件上传,该如何解决

Jun 13, 2016 am 10:08 AM
php quot

php 视频、音频和图片文件上传
哪位大师晒个php、音频和图片文件上传的实例。。。。感谢!!!!!!!!!!!!!!!!!!!!!!!!!!

------解决方案--------------------
http://www.w3school.com.cn/php/php_file_upload.asp
有完整的代码跟讲解
------解决方案--------------------
普通HTML上传视频恐怕有点难度吧。一般视频文件比较大,都是几百MB吧。而且在外网的话网速也不怎么稳定。
上传几百MB的文件可能要花很长时间吧,服务器如果给每个用户这么长的连接时间那其它的用户都无法访问了。

QQ邮箱中有一个大附件上传功能,他有断点续传功能。像视频这类的大文件上传最好借助于断点续传功能来实现。

图片上传网上的示例比较多。比如swfupload等。
------解决方案--------------------
网上有一个PHP断点续传的示例。

PHP code
<?phpob_start ();$uploadDir = dirname(__FILE__).'/upload'; //自动创建目录if(!file_exists($uploadDir)){     mkdir($uploadDir);} //如果PHP页面为UTF-8编码,请使用urldecode解码文件名称//$fileName = urldecode($_FILES['postedFile']['name']);//如果PHP页面为GB2312编码,则可直接读取文件名称$fileName = basename($_FILES['FileName']['name']);//qq.exe$tmpFilePath = $uploadDir . "/" . $fileName . ".tmp";$tmpName = $_FILES['FileName']['tmp_name'];$FileSize = $_POST['FileSize'];$md5     = $_POST['md5'];$complete = $_POST['complete'];$RangePos = $_POST['RangePos']; //移动文件move_uploaded_file($tmpName,$tmpFilePath); //upload/qq.exe$savePath = $uploadDir . "/" . $fileName; //文件不存在,创建if(!file_exists($savePath)){     $hfile = fopen($savePath,"wb");     ftruncate($hfile,$FileSize);     fclose($hfile);} //读取文件块数据$hfileTemp = fopen($tmpFilePath,"rb");$tempData = fread($hfileTemp,filesize($tmpFilePath));fclose($hfileTemp); //写入数据$hfile = fopen($savePath,"r+b");//定位到续传位置fseek($hfile, $RangePos,SEEK_SET);fwrite($hfile,$tempData);fclose($hfile); //删除临时文件unlink($tmpFilePath); //输出文件路径//$_SERVER['HTTP_HOST'] localhost:81//$_SERVER['REQUEST_URI'] /FCKEditor2.4.6.1/php/test.php //$reqPath = str_replace("upload.php","",$_SERVER['REQUEST_URI']);echo "upload/" .  $fileName;header('Content-Length: ' . ob_get_length()); ?><br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

网上有一个PHP断点续传的示例。
PHP code

ob_start();

$uploadDir = dirname(__FILE__).'/upload';



//自动创建目录

if(!file_exists($uploadDir)){

mkdir($uploadDir);

}



//如果PHP页面为UTF-8编码,请使用urldecode解码文……

------解决方案--------------------
探讨
哪位大师晒个php、音频和图片文件上传的实例。。。。感谢!!!!!!!!!!!!!!!!!!!!!!!!!!

------解决方案--------------------
PHP视频文件上传示例:http://www.cnblogs.com/xproer/archive/2012/02/17/2355467.html
楼主在网上搜一下吧,网上挻多的。
------解决方案--------------------
观摩中。有用http://www.swfupload.org/project的
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

See all articles