[英]How to set Ajax Upload of Img File in Codeigniter
我阅读了许多有关使用codeigniter上载文件的教程,但问题是这些教程在我的情况下无法正常工作,并且我无法通过ajax上载成功,请求失败,并且页面在非ajax的导航栏中加载,我想要找到一个非常详细的教程来解释codeigniter中ajax上传的基础。 或有关该主题的一些建议。
该代码对我来说很好,您只需要在控制器上对其进行管理即可。
不要忘记添加jquery.form.min.js。
<script>
function service_switch()
{
$('#service_update').ajaxSubmit({
beforeSubmit: function() {
$("#switch").html('<img alt=""'+
' src="<?=base_url()."assets/default/"?>img/preloaders/ajax-loader.gif" align="center" /> 0% Switching.');
},
uploadProgress: function (event, position, total, percentComplete){
$("#switch").html('<img alt=""'+
' src="<?=base_url()."assets/default/"?>img/preloaders/ajax-loader.gif" align="center" /> '+perc+'% Switching ...');
},
success:function (d){
if(d=='success'){
$("#switch").html(' 100% Switched Successfully !');
}else{
$("#switch").html(' '+d);
}
},
error:function(){$("#switch").html('segmentation fault');},
resetForm: true
});
}
</script>
<!--Firmware MAC Configuaration Form-->
<?php
//shell_exec("gnome-terminal -e ping 127.0.0.1 &");
//shell_exec("geany");
$attribute = array('class'=> 'box validate','id'=>'service_update');?>
<?php echo form_open('firmware_update/service_switch',$attribute);?>
<div class="header">
<h2>
Service Update
</h2>
</div>
<div class="content">
<div class="row">
<label>
<strong>Switch Service </strong>
</label>
<div>
<div>
<input type="radio" name="demo" id="demo1" value="1">
<label for="demo1">demo1</label>
</div>
<div>
<input type="radio" name="demo" id="demo2" value="2">
<label for="f4_rb_dis2">service2_RX</label>
</div>
<div>
<input type="radio" name="demo" id="demo3" value="3">
<label for="demo1">service2_TX</label>
</div>
<div>
<input type="radio" name="demo" id="demo4" value="4">
<label for="demo1">service3</label>
</div>
</div>
</div>
</div>
<div class="actions">
<div class="right">
<a onclick="service_switch();" class="button blue flat" >Switch Service</a>
</div>
</div>
<?php echo form_close(); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.