PHP code<?php
ob_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());
?>
------解决方案--------------------探讨
网上有一个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的