Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php parameter return? #22

Open
landolphin opened this issue Jan 29, 2019 · 1 comment
Open

Php parameter return? #22

landolphin opened this issue Jan 29, 2019 · 1 comment

Comments

@landolphin
Copy link

Hi, I use the Chinese ThinkPHP framework. The framework's upload class. Is the php return parameter the above? Also, how do I get the name of the uploaded file?

@landolphin
Copy link
Author

`$('#demo-fileInput-4').filer({
changeInput: '

上传文件
',
showThumbs: true,
theme: "dragdropbox",
limit:"1",
extensions:['jpg','jpeg','png','gif'],
/* files: [
{
name: "appended_file.jpg",
size: 5453,
type: "image/jpg",
file: "http://dummyimage.com/720x480/f9f9f9/191a1a.jpg"
},
{
name: "appended_file_2.jpg",
size: 9453,
type: "image/jpg",
file: "http://dummyimage.com/640x480/f9f9f9/191a1a.jpg"
}
],*/

templates: {
    box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>',
    item: '<li class="jFiler-item">\
                <div class="jFiler-item-container">\
                    <div class="jFiler-item-inner">\
                        <div class="jFiler-item-thumb">\
                            <div class="jFiler-item-status"></div>\
                            <div class="jFiler-item-info">\
                                <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                <span class="jFiler-item-others">{{fi-size2}}</span>\
                            </div>\
                            {{fi-image}}\
                        </div>\
                        <div class="jFiler-item-assets jFiler-row">\
                            <ul class="list-inline pull-left">\
                                <li>{{fi-progressBar}}</li>\
                            </ul>\
                            <ul class="list-inline pull-right">\
                                <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                            </ul>\
                        </div>\
                    </div>\
                </div>\
            </li>',
    itemAppend: '<li class="jFiler-item">\
                    <div class="jFiler-item-container">\
                        <div class="jFiler-item-inner">\
                            <div class="jFiler-item-thumb">\
                                <div class="jFiler-item-status"></div>\
                                <div class="jFiler-item-info">\
                                    <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                    <span class="jFiler-item-others">{{fi-size2}}</span>\
                                </div>\
                                {{fi-image}}\
                            </div>\
                            <div class="jFiler-item-assets jFiler-row">\
                                <ul class="list-inline pull-left">\
                                    <li><span class="jFiler-item-others">{{fi-icon}}</span></li>\
                                </ul>\
                                <ul class="list-inline pull-right">\
                                    <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                </ul>\
                            </div>\
                        </div>\
                    </div>\
                </li>',
    itemAppendToEnd: false,
    removeConfirmation: true,
    _selectors: {
        list: '.jFiler-items-list',
        item: '.jFiler-item',
        remove: '.jFiler-item-trash-action'
    }
},
 uploadFile: {
    url: "{$Site.BaseURL}/public/index.php/crm/Staff/upload",
    data: null,
    type: 'POST',
    enctype: 'multipart/form-data',
    beforeSend: function(){},
    success: function(data, el){
        var parent = el.find(".jFiler-jProgressBar").parent();
        el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
            $("&lt;div class=\"jFiler-item-others text-success\">&lt;i class=\"icon-jfi-check-circle\">&lt;/i> Success&lt;/div>").hide().appendTo(parent).fadeIn("slow");    
        });
		var json=eval(data);
		//上传成功后
	//	alert(json.data.src)
	console.log(data);
    },
    error: function(el){
        var parent = el.find(".jFiler-jProgressBar").parent();
        el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
            $("&lt;div class=\"jFiler-item-others text-error\">&lt;i class=\"icon-jfi-minus-circle\">&lt;/i> Error&lt;/div>").hide().appendTo(parent).fadeIn("slow");    
        });
    },
    statusCode: null,
    onProgress: null,
    onComplete: null
},

 //删除文件
 onRemove: function(itemEl, file){
    var file = file.name;
   // $.post('./php/remove_file.php', {file: file});
   alert('xxx');
}

}); `

`public function upload(){

  $files  = request()->file('files');
  foreach($files as $file){
  $info = $file->move( '../uploads/admin/');
    if($info){

      $filename=$info->getSaveName();

      //上传到七牛云
      $qiniu_event =controller('crm/Upload', 'behavior');
      $PusFile="../uploads/admin/".$filename;
	  $qiniuurl=$qiniu_event->run($PusFile);
	 // unlink($PusFile);

     // $data=["code"=>0,"msg"=>0,"data"=>["src"=>"{$qiniuurl}"]];
     // exit(json_encode($data));
	   print_r($files);
    }else{
        // 上传失败获取错误信息
        echo $file->getError();
     }
    }

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant