2
我一直在試圖上傳一個zip文件與Codeigniter,我以前做過的事情,但似乎無法看到這次上班。下面是我的文件:CodeIgniger文件上傳,無法識別錯誤
查看:
<h2>Add a New Album</h2>
<form method="post" enctype="multipart/form-data" action="<?php echo base_url(); ?>index.php/photo/newAlbum">
<table>
<tr>
<td><p>Album Name:</p></td>
<td><input type="text" name="aName" /></td>
</tr>
<tr>
<td><p></p></td>
<td><input type="file" name="userfile" size="20" /></td>
</tr>
<tr>
<td><p></p></td>
<td><input type="submit" value="Upload Images and Create Gallery" /></td>
</tr>
</table>
</form>
控制器:
$config['upload_path'] = $path;
$config['allowed_types'] = 'zip';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile'))
{
$data['message'] = $this->upload->display_errors();
$this->template->load('admin/template', 'admin/msg', $data);
}
else
{ $codeToBeWrittin }
的錯誤:
You did not select a file to upload.
聽起來像你的任何數據都沒有到達控制器,請嘗試echo var_dump($ _ POST);並看看你是否至少從窗體中獲得aName字段。從那裏開始。 – bonez
感謝您的提示,但是現在我看到,當我的表單具有enctype =「multipart form-data」時,沒有數據會通過。但是,當我不添加它時,發佈數據會通過,但沒有文件上傳。任何想法... – b2000b
您是否嘗試過使用CI的表單助手來生成測試表單? 'form_open_multipart()' - http://codeigniter.com/user_guide/helpers/form_helper.html – polarblau