Php Codeigniter:多文件上载
我尝试了许多可以与codeigniter集成的多文件上传程序,比如Php Codeigniter:多文件上载,php,codeigniter,jquery-file-upload,multifile-uploader,Php,Codeigniter,Jquery File Upload,Multifile Uploader,我尝试了许多可以与codeigniter集成的多文件上传程序,比如 纸浆负荷 jquery文件上传 尽管它们在纯php环境中工作得很好,但我无法让它们在codeigniter框架中工作。我试了两天。。尝试了github和博客上的许多文章。。 但我无法在codeigniter框架中实现。。 如果有人能一步一步地告诉我,或者有教程,请帮助我。 我是一个新的代码点火器 新的: 我下载了blueimp Jquery文件上传插件,并按原样点击了这个链接。。 当我选择一个文件并在chrome中单击up
- 纸浆负荷
- jquery文件上传
Error SyntaxError: Unexpected token <
我检查了在我的服务器上使用它和在演示服务器上使用它之间的区别,在firebug中我的服务器上,POST返回的是整个index.html。。。
但在演示服务器上,它返回JSON数据
以下是我更改的js/main.js的修改部分:
$(function () {
'use strict';
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: 'upload/do_upload'
});
// Enable iframe cross-domain access via redirect option:
$('#fileupload').fileupload(
'option',
'redirect',
window.location.href.replace(
/\/[^\/]*$/,
'/cors/result.html?%s'
)
);
if (window.location.hostname === 'blueimp.github.io') {
// Demo settings:
$('#fileupload').fileupload('option', {
url: '//jquery-file-upload.appspot.com/',
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
maxFileSize: 5000000,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
});
// Upload server status check for browsers with CORS support:
if ($.support.cors) {
$.ajax({
url: '//jquery-file-upload.appspot.com/',
type: 'HEAD'
}).fail(function () {
$('<div class="alert alert-danger"/>')
.text('Upload server currently unavailable - ' +
new Date())
.appendTo('#fileupload');
});
}
} else {
// Load existing files:
$('#fileupload').addClass('fileupload-processing');
$.ajax({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: $('#fileupload').fileupload('option', 'url'),
dataType: 'json',
context: $('#fileupload')[0]
}).always(function () {
$(this).removeClass('fileupload-processing');
}).done(function (result) {
$(this).fileupload('option', 'done')
.call(this, $.Event('done'), {result: result});
});
}
$(函数(){
"严格使用",;
//初始化jQuery文件上载小部件:
$('#fileupload')。fileupload({
//取消对以下内容的注释以发送跨域cookie:
//xhrFields:{withCredentials:true},
url:“上传/不上传”
});
//通过重定向选项启用iframe跨域访问:
$('#fileupload')。fileupload(
“选项”,
“重定向”,
window.location.href.replace(
/\/[^\/]*$/,
“/cors/result.html?%s”
)
);
if(window.location.hostname=='blueimp.github.io'){
//演示设置:
$('#fileupload')。fileupload('选项'{
url:“//jquery file upload.appspot.com/”,
//启用图像大小调整,Android和Opera除外,
//它实际上支持图像大小调整,但无法
//通过XHR请求发送Blob对象:
disableImageResize:/Android(?。*Chrome)| Opera/
.test(window.navigator.userAgent),
最大文件大小:5000000,
acceptFileTypes:/(\.\/)(gif | jpe?g | png)$/i
});
//支持CORS的浏览器的上载服务器状态检查:
如果($.support.cors){
$.ajax({
url:“//jquery file upload.appspot.com/”,
类型:“头”
}).fail(函数(){
$('')
.text('上载服务器当前不可用-'+
新日期()
.appendTo(“#fileupload”);
});
}
}否则{
//加载现有文件:
$('#fileupload').addClass('fileupload-processing');
$.ajax({
//取消对以下内容的注释以发送跨域cookie:
//xhrFields:{withCredentials:true},
url:$('#fileupload')。fileupload('option','url'),
数据类型:“json”,
上下文:$('#fileupload')[0]
}).always(函数(){
$(this.removeClass('fileupload-processing');
}).完成(功能(结果){
$(此).fileupload('option','done')
.call(this,$.Event('done'),{result:result});
});
}
}))
我唯一改变的是制作index.html,使表单操作指向我的脚本(上传/上传)显示您尝试的代码,然后修复它是可能的解决方案。。任何方式都有你应该使用的文件上传程序库。如果谷歌或codeigniter文档对你没有帮助,那么你可以雇佣people@Fisherman-我更具体地更新了问题。。你能帮我吗?
$(function () {
'use strict';
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: 'upload/do_upload'
});
// Enable iframe cross-domain access via redirect option:
$('#fileupload').fileupload(
'option',
'redirect',
window.location.href.replace(
/\/[^\/]*$/,
'/cors/result.html?%s'
)
);
if (window.location.hostname === 'blueimp.github.io') {
// Demo settings:
$('#fileupload').fileupload('option', {
url: '//jquery-file-upload.appspot.com/',
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
maxFileSize: 5000000,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
});
// Upload server status check for browsers with CORS support:
if ($.support.cors) {
$.ajax({
url: '//jquery-file-upload.appspot.com/',
type: 'HEAD'
}).fail(function () {
$('<div class="alert alert-danger"/>')
.text('Upload server currently unavailable - ' +
new Date())
.appendTo('#fileupload');
});
}
} else {
// Load existing files:
$('#fileupload').addClass('fileupload-processing');
$.ajax({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: $('#fileupload').fileupload('option', 'url'),
dataType: 'json',
context: $('#fileupload')[0]
}).always(function () {
$(this).removeClass('fileupload-processing');
}).done(function (result) {
$(this).fileupload('option', 'done')
.call(this, $.Event('done'), {result: result});
});
}