不知道你是想知道前台的是怎么提交到后台的?还是想知道后台是怎么处理?我分别给你解释一下。
uploadify 上传时在网页 创建一个iframe,然后在该iframe进行上传,也可以使flash上传,后台获取数据之后通过$_FILES来进行文件上传的 *** 作。所以这个插件本质上跟表单post是一样的。
关于上传文件:
推荐使用插件Uploadify!
使用方法:>
下载地址:>
关于多图上传:
在客户端定义一个js变量,用于缓存每次异步上传路径;
最后提交表达数据的时候就把这些路径集合保存到数据库即可!
有种回答叫做我不知道!
<html><title>我真的什么都不知道!<title>
</html>
新手解答:望对您有用处!
以下是我的部分代码:
上传目录应该是没有问题;
//以下是html页面的script
<script>
<php $timestamp = time();>
$(function() {
$('#file_upload')uploadify({
auto:false,
buttonCursor: 'hand',
successTimeout: 6000,
removeTimeout: 30,
buttonText: '<div>选择</div>',
'fileDataName':'Filedata',
'fileExt': '',
fileTypeDesc: '请选择文件',
'formData': {
timestamp: '<php echo $timestamp;>',
token: '<php echo md5('unique_salt' $timestamp);>'
},
multi: true,
progressData: 'percentage',
successTimeout: 600,
swf: '/uploadify/uploadifyswf',
uploader: "{:U('Admin/App/uploadify',"id=$id")}",
'onUploadSuccess' : function(file, data, response) {
alert('文件 ' + filename + ' 上传的结果 ' + response + ':' + data);
}
})
});
</script>
---------------------------------------------------------------------------------------------
//以下是php控制器的方法
public function uploadify(){//上传横图
$targetFolder = '/uploads'; // Relative to the root
$verifyToken = md5('unique_salt' $_POST['timestamp']);
$id=$_GET['id'];
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
//临时文件的文件名
$tempFile = $_FILES['Filedata']['tmp_name'];
//上传过来的文件的路径 目标目录
$targetPath = $_SERVER['DOCUMENT_ROOT'] $targetFolder;
// 验证文件类型
$fileTypes = array('jpg','jpeg','gif','png','bmp'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
//var_dump($fileParts);exit;
//随机获取文件名+ 取得上传文件的后缀
$filename=mt_rand(99,99999999)''$fileParts['extension'];
//拼凑路径
$targetDir = rtrim($targetPath,'/') '/' $id;
//拼凑文件名
$targetFile = $targetDir '/'$filename;
//如果不存在带id的文件夹,就创建这个文件夹
if (!file_exists($targetDir))
@mkdir($targetDir,0777,true);
//验证上传文件是否符合条件 符合就把上传文件移动到目标路径
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
//数据入库
}
}
------------------------------------------------------------------------------------------------------
以上就是关于thinkphp批量上传uploadify 谁知道图片路径怎么存数据库里跪求全部的内容,包括:thinkphp批量上传uploadify 谁知道图片路径怎么存数据库里跪求、thinkphp 多图上传,如何把图片路径保存到数据库、thinkphp上传类怎么把上传路径返回到表单等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)