php保存上传的音频文件在哪里,php 视频、音频和图片文件上传,该如何解决

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的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值