请问这个jquery uploadify 上传插件要怎样更改 fileObj.filePath 的值,因为我想要改变成我重新命名的路径一下是upload.php 的代码
if (!empty($_FILES)) {
$attach = array();
$tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$targetPath = $ATTACH_PATH.'/'.date("Ym")."/";
if(!file_exists($targetPath))mkdir($targetPath);
//重命名
$showtime=date("YmdHis");
$fileExt = get_ext($fileName);
$attach['filename'] = $showtime.".".$fileExt;
$targetFile = $attach['path'] = $targetPath.$showtime.".".$fileExt;
//判断后缀,看是否允许上传该类型附件
if($NOTALLOW_FILETYPE && in_array($fileExt, $NOTALLOW_FILETYPE)){
echo "系统不允许上传此类型的文件!";
die();
}
move_uploaded_file($tempFile,iconv("UTF-8","gb2312",$targetFile));
//初始化次序
$order = n_fetch("SELECT max(attach_order)+1 FROM `attach`");
if(!$order)$order = 1; //入库
m_query("INSERT INTO `attach` (`filename` ,`path` ,`date`,`attach_order`)VALUES
('$fileName', '$targetFile', now(), $order)");
$attach['attach_id'] = mysql_insert_id();
echo $attach['attach_id'];
//生成缩略图
set_thumb($attach);
这是加载的代码$("#file").uploadify({
'uploader' : 'javascript/uploadify.swf',
'cancelImg' : 'css/uploadify/cancel.png',
'script' : 'upload.php',
'folder' : '<?=$ATTACH_PATH."/".date("Ym")?>',
'buttonImg' : 'css/uploadify/upload.png',
'auto' : true,
'multi' : true,
'onComplete' : function(event, queueID, fileObj, response){
if(isNaN(response)){
//上传报错
alert(response);
}else if(response){
//显示并加入元素
add_attach(response,fileObj.name,newpathyes);
}
}
});
if (!empty($_FILES)) {
$attach = array();
$tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$targetPath = $ATTACH_PATH.'/'.date("Ym")."/";
if(!file_exists($targetPath))mkdir($targetPath);
//重命名
$showtime=date("YmdHis");
$fileExt = get_ext($fileName);
$attach['filename'] = $showtime.".".$fileExt;
$targetFile = $attach['path'] = $targetPath.$showtime.".".$fileExt;
//判断后缀,看是否允许上传该类型附件
if($NOTALLOW_FILETYPE && in_array($fileExt, $NOTALLOW_FILETYPE)){
echo "系统不允许上传此类型的文件!";
die();
}
move_uploaded_file($tempFile,iconv("UTF-8","gb2312",$targetFile));
//初始化次序
$order = n_fetch("SELECT max(attach_order)+1 FROM `attach`");
if(!$order)$order = 1; //入库
m_query("INSERT INTO `attach` (`filename` ,`path` ,`date`,`attach_order`)VALUES
('$fileName', '$targetFile', now(), $order)");
$attach['attach_id'] = mysql_insert_id();
echo $attach['attach_id'];
//生成缩略图
set_thumb($attach);
这是加载的代码$("#file").uploadify({
'uploader' : 'javascript/uploadify.swf',
'cancelImg' : 'css/uploadify/cancel.png',
'script' : 'upload.php',
'folder' : '<?=$ATTACH_PATH."/".date("Ym")?>',
'buttonImg' : 'css/uploadify/upload.png',
'auto' : true,
'multi' : true,
'onComplete' : function(event, queueID, fileObj, response){
if(isNaN(response)){
//上传报错
alert(response);
}else if(response){
//显示并加入元素
add_attach(response,fileObj.name,newpathyes);
}
}
});
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货