我的解决办法.与js无关.具体看注释
```php
一,上传时,先调用了这一个文件.
Application\Core\Controller\FileController.class.php
public function uploadPictureUM()
{
header("Content-Type:text/html;charset=utf-8");
$return = array('status' => 1, 'info' => L('_SUCCESS_UPLOAD_'), 'data' => '');
$originalName = 'u=2830036734,2219770442&fm=21&gp=0.jpg';
$newFilename = '14035912861705.jpg';
$filePath = 'upload\/20140624\/14035912861705.jpg';
$size = '7446';
$type = '.jpg';
$status = 'success';
$rs = array(
"originalName" => $originalName,
'name' => $newFilename,
'url' => $filePath,
'size' => $size,
'type' => $type,
'state' => $status,
'original' => $_FILES['upfile']['name']
);
$Picture = D('Admin/Picture');
$setting = C('EDITOR_UPLOAD');
$setting['rootPath']='./Uploads/Editor/Picture/';
$driver = modC('PICTURE_UPLOAD_DRIVER','local','config');
$driver = check_driver_is_exist($driver);
$uploadConfig = get_upload_config($driver);
$info = $Picture->upload(
$_FILES,
$setting,
$driver,
$uploadConfig
);
if ($info) {
$return['status'] = 1;
if ($info['Filedata']) {
$return = array_merge($info['Filedata'], $return);
}
if ($info['download']) {
$return = array_merge($info['download'], $return);
}
$rs['state'] = 'SUCCESS';
$rs['url'] = $info['upfile']['path'];
if ($type == 'ajax') {
echo json_encode($rs);
exit;
} else {
echo json_encode($rs);
exit;
}
} else {
$return['state'] = 0;
$return['info'] = $Picture->getError();
}
$this->ajaxReturn($return);
}
二,然后再调用这个文件
Application\Admin\Model\PictureModel.class.php
原因应该是这里调用了后面的方法,但是没通过$this->create($value) && ($id = $this->add(),具体原因就不去查了.
PictureModel的文件内容为:
public function upload($files, $setting, $driver = 'local', $config = null){
$setting['callback'] = array($this, 'isFile');
$setting['removeTrash'] = array($this, 'removeTrash');
$Upload = new Upload($setting, $driver, $config);
foreach ($files as $key => $file) {
$ext = strtolower($file['ext']);
if(in_array($ext, array('jpg','jpeg','bmp','png'))){
hook('dealPicture',$file['tmp_name']);
}
}
$info = $Upload->upload($files);
if($info){
foreach ($info as $key => &$value) {
if(isset($value['id']) && is_numeric($value['id'])){
continue;
}
if(strtolower($driver)=='sae'){
$value['path'] = $config['rootPath'].'Picture/'.$value['savepath'].$value['savename'];
}else{
if(strtolower($driver) != 'local'){
$value['path'] =$value['url'];
}
else{
$value['path'] = (substr($setting['rootPath'], 1).$value['savepath'].$value['savename']);
}
}
$value['type'] = $driver;
if($this->create($value) && ($id = $this->add())){
$value['id'] = $id;
} else {
}
}
foreach($info as &$t_info){
if($t_info['type'] =='local'){
$t_info['path']=get_pic_src($t_info['path']);
}
else{
$t_info['path']=$t_info['path'];
}
}
return $info;
} else {
$this->error = $Upload->getError();
return false;
}
}