0
這是我的代碼,在我的codeigniter代碼中使用ajaxfileupload和Jquery上傳圖像。但codeigniter代碼在日誌文件中給出錯誤。它的上傳。但是當我測試沒有jQuery和ajaxfileupload腳本的代碼時。codeigniter ajaxfileupload.js腳本錯誤 - 您沒有選擇要上傳的文件
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="//localhost/AjaxFileUploader/ajaxfileupload.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#form").change(function() {
$("#upload").html('<img src="loader.gif"/>');
$.ajaxFileUpload({
url: 'http://localhost/ci/index.php/upload/do_upload',
secureuri: false,
fileElementId: 'userfile',
dataType: 'json',
success: function (data, status) {
if (typeof (data.error) != 'undefined') {
if (data.error != '') {
alert(data.error);
} else {
alert(data.msg);
}
}
},
error: function (data, status, e) {
alert(e);
}
});
});
});
</script></head>
<body>
<form action="http://localhost/ci/index.php/upload/do_upload" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<input type="file" name="userfile" size="20" id="form" />
<br /><br />
<input type="submit" value="upload" id="submit" />
<span id="upload"></span>
</form></body>
</html>
和我笨代碼
function do_upload()
{
$config['upload_path'] = 'c:\upload';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['encrypt_name'] = TRUE;
$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);
}
}
但笨不上傳文件。它會在日誌文件中發出錯誤,如「您沒有選擇要上載的文件」。
它不工作... ..科林我 – user1130639
嘗試,,但它不工作 – user1130639