Call to a member function move() on null这个问题怎么解决啊?
html:
<input type="file" name="file_img" id="file_upload" />
<script>
$(function() {
$("#file_upload").uploadify({
'auto' : true,
'buttonClass':'layui-btn layui-btn-warm',
'swf' : '__STATIC__/common/uploadify/uploadify.swf',
'uploader' : "{:url('index/baiduimg/upload')}" ,
'fileTypeDesc': "请选择",
'buttonText':'选择图片',
'fileobjname':'file_img',
'fileTypeDesc' : '只支持jpg和png',
'fileTypeExts' : '*.jpg; *.png',
'onFallback':function(){
alert('文件flash出错');
},
'progressData':'speed',
/*'onUploadProgress':function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal){
$('#progress').html(totalBytesUploaded + ' bytes uploaded of ' + totalBytesTotal + ' bytes.');
},*/
'onUploadSuccess':function(file,data,response){
alert('The file ' + file.name + ' was successfully uploaded ');
}
php:
<?php
namespace app\index\controller;
use think\Controller;
use baiduimg\AipImageSearch;
use think\File;
class Baiduimg extends Controller{
public function index(){
return $this->fetch();
}
public function upload(){
$file=request()->file('file_img');
print_r($file) ;
$info=$file->move(ROOT_PATH . 'public' . DS . 'uploads'.DS.'images');
if($info){
echo $info->getSaveName();
}
}
}