Php Codeigniter未上载png格式的图像文件
Codeigniter 3.1.6是我正在使用的版本。当我尝试上传jpg格式的文件时,它是成功的,但是上传png格式的文件不起作用。这是我的代码。我正在使用dropzone.js上传文件 观点Php Codeigniter未上载png格式的图像文件,php,codeigniter,file-upload,dropzone.js,Php,Codeigniter,File Upload,Dropzone.js,Codeigniter 3.1.6是我正在使用的版本。当我尝试上传jpg格式的文件时,它是成功的,但是上传png格式的文件不起作用。这是我的代码。我正在使用dropzone.js上传文件 观点 这可以通过使用CI上载库轻松完成。首先,您需要在config->autoload.php中加载库 $autoload['libraries'] = array('upload'); 或者在你的控制器中 class ImageUpload extends CI_Controller
这可以通过使用CI上载库轻松完成。首先,您需要在config->autoload.php中加载库
$autoload['libraries'] = array('upload');
或者在你的控制器中
class ImageUpload extends CI_Controller
{
public function Upload()
{
if($_FILES["uploadImage"]["error"]==4)//check if user select input any image to upload
{
$config['Upload_Path']='';//File upload path
$config['allowed_types']='jpeg|jpg|png';//set the preferred file formats here
$config['max_size']=100000;// Max File Size
if($this->upload->do_upload('uploadImage'))//uploading the data
{
$uploadData=$this->upload->data();//get the details of uploaded data
}else
{
$error=$this->upload->display_errors();//this return the error message if any error thrown
}
}
}
}
为什么不使用codeigniter文件上载库打印\r$\u文件;查看有什么错误。@Mr.ED Sarry idk我是如何尝试的你能给我看一个可能的代码吗?必须指出你的类在codeigniter的最新版本中命名错误只有第一个字母应该是大写的文件名和类名在这里解释,或者尽管它可能在某些系统上工作,最好按照用户指南i中的方式命名codeigniter看到这些错误,我的文件超过了php的最大文件大小,谢谢你的代码
$autoload['libraries'] = array('upload');
class ImageUpload extends CI_Controller
{
public function Upload()
{
if($_FILES["uploadImage"]["error"]==4)//check if user select input any image to upload
{
$config['Upload_Path']='';//File upload path
$config['allowed_types']='jpeg|jpg|png';//set the preferred file formats here
$config['max_size']=100000;// Max File Size
if($this->upload->do_upload('uploadImage'))//uploading the data
{
$uploadData=$this->upload->data();//get the details of uploaded data
}else
{
$error=$this->upload->display_errors();//this return the error message if any error thrown
}
}
}
}