Php codeigniter文件上载失败
无法上载文件<代码>$this->upload->do_upload('anosphoto')代码>返回Php codeigniter文件上载失败,php,upload,codeigniter-2,Php,Upload,Codeigniter 2,无法上载文件$this->upload->do_upload('anosphoto')返回false。不知道为什么 我通过以下方式将upload library添加到自动加载中:$autoload['libraries']=array('upload') 以下是我的看法: <?php echo form_open_multipart('InterviewController/saveInterview'); $anons_data = array( 'name' =
false
。不知道为什么
我通过以下方式将upload library添加到自动加载中:$autoload['libraries']=array('upload')代码>
以下是我的看法:
<?php
echo form_open_multipart('InterviewController/saveInterview');
$anons_data = array(
'name' => 'anons',
'id' => 'anons_area',
'value' => 'Введите анонс'
);
echo form_textarea($anons_data); ?>
<p>Картинка анонса</p>
<?php
echo form_upload('anonsphoto'); ?>
上传文件为3KB大小的png文件。我不明白为什么do_upload返回false。有什么想法吗?我认为你的上传路径是错误的。试用
$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'].'/application/upload/';
并确保目录是可写的。文件上载类会显示所有您需要的内容
这是一个关键:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
// Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class:
$this->upload->initialize($config);
“”(点)表示当前上传路径的目录。因此,您的应用程序无法运行,因为您所在的根路径不是以(点)开头的
您的文件夹应具有0755的完全权限(CHMOD)
这:
表示:当前目录和上载目录
或:
意思是:您的完整文档URI路径和目录'/application/upload/'
,如Can所述
别忘了放(点)。在$\u服务器['DOCUMENT\u ROOT']
和'/application/upload'
之间
最大大小应为KiB值:$config['Max_size']='10000'代码>
希望这有助于理解它的工作原理。codeigniter无法覆盖php.ini中设置的上传限制。检查上载的最大大小值。尝试echo$this->upload->display_errors()代码>。我仅使用路径“应用程序/上传”就解决了问题。前无点,后无/。这是什么意思?
点确保它位于当前目录中。在linux上,主要用于TED或FTP。若您把/
的意思放在文件系统的根目录下,这也可以避免混淆。当您放置/
时,表示转到当前目录。希望这有帮助。
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
// Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class:
$this->upload->initialize($config);
$config['upload_path'] = './uploads/';
$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'].'/application/upload/';