图片上传问题
本帖最后由 fastammo 于 2015-1-28 16:36 编辑资料夹权限有设定777,但传不上去,不清楚是哪边出错
view
<form id="frm">
<div class="form">
<table class="form_table2">
<tr>
<th>名字</th>
<td>
<input name="name" type="text" id="name">
</td>
<th>上傳</th>
<td>
<input name="img1" type="file" id="img1">
<input name="img2" type="file" id="img2">
</td>
</tr>
</table>
</div>
<div class="btn">
<a class="send">送出</a>
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$('a.send').click(function(){
$.post('/upload_file/', $('#frm').serialize() , function(data) {
}, 'json');
});
});
</script>
controllers
function do_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);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form',$error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success',$data);
}
$send_data = $this->input->post(NULL, TRUE);
$data = $this->send_model->register_send($send_data );
}
看一下手冊 這篇 的 form_open_multipart() 你好,我参考官方范例不能运行,请问有可以跑的范例吗?
http://www.codeigniter.org.tw/user_guide/libraries/file_uploading.html 本帖最后由 Closer 于 2015-1-29 10:31 编辑
fastammo 发表于 2015-1-29 10:03
你好,我参考官方范例不能运行,请问有可以跑的范例吗?
http://www.codeigniter.org.tw/user_guide/librari ...
基本上官網的範例就能跑了
你有出現甚麼錯誤訊息嗎?
從網站複製的代碼要注意 , 號的全形半形 Fatal error: Class 'CI_Model' not found in /var/www/application/hooks/ssl.php on line 3
SSL的部分
ssl.php
class Check_ssl extends CI_Model {
function __construct()
{
parent::__construct();
$this->load->helper('url');
}
function check_ssl()
{
$CI =& get_instance();
$class = $CI->router->fetch_class();
$method = $CI->router->fetch_method();
$CI =& get_instance();
$CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 443) redirect($CI->uri->uri_string());
}
}
fastammo 发表于 2015-1-29 10:34
Fatal error: Class 'CI_Model' not found in /var/www/application/hooks/ssl.php on line 3
SSL的部分
ss ...
你額外的 hook ... 這我就不清楚了
還沒去玩過那個功能
純 CI 文檔 + 範例是可以跑的 感谢...会再试试看 fastammo 发表于 2015-1-29 10:39
感谢...会再试试看
抱歉呢~ 沒幫上忙
我會介紹你去看 form_open_multipart() 的原因是
你的 form 並沒有指定 multipart 形式
預設的 form 是沒辦法上傳檔案 别这么说,你很尽力帮助我们解决问题,真的很感谢你! 是没加enctype吧
页:
[1]
2