Codeigniter - Uploadify:显示HTTP错误

时间:2013-03-07 13:01:24

标签: codeigniter uploadify

我正在使用Codeigniter并希望使用“Uploadify”上传CSV文件。实际上它以前工作,但现在它显示'HTTP错误'。下面我给出了我的代码:

视图:

<input id="upload_csv" name="upload_csv" type="file" />
<a href="javascript:$('#upload_csv').uploadifyUpload();" class="btn large primary">Upload</a>

uploadify.php代码如下:

function filemanipulation_csv($extension, $filename) {
        if ($this->is_image($extension)) {
            $config['image_library'] = 'gd2';
            $config['source_image'] = base_url() . 'csv/' . $filename;
            $config['create_thumb'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            $config['thumb_marker'] = '';
            $config['width'] = 100;
            $config['height'] = 100;
            $this->load->library('image_lib', $config);
            $this->image_lib->resize();
            echo 'image';
            exit;
        }
        else
            echo 'file';
    }

和我的vortex.js包含:

var base_url = $('#hiddenBaseUrl_photo_audio').val();
    var uploadfolder = $('#csv_upload_folder').val();  
    $('#upload_csv').uploadify({     
        'uploader'  : base_url + 'asset/flash/uploadify/uploadify.swf',
        'script'    : base_url + 'index.php/uploadify/uploadifyUploader/',
        'cancelImg' : base_url + 'asset/images/cancel.png',
        'folder'    : uploadfolder,
        'fileExt'     : '*.mp3;',
        'data' :  base_url +'fileObj.name',
        'auto'      : false,
        'multi'     : false,
        'onComplete'  : function(event, ID, fileObj, response, data) {
         var validExtensions = ['mp3']; //array of valid extensions
            var fileName = $("#csvfile").val();
            var fileNameExt = fileName.substr(fileName.lastIndexOf('.') + 1);    
            if ($.inArray(fileNameExt, validExtensions) == -1){
                alert("Invalid file type. Please upload only mp3 files.");
                $("#yourElem").uploadifyCancel(q);
                return false;
            }
            else{
                $.ajax({
                    url : base_url + 'index.php/uploadify/filemanipulation_csv/' + fileObj.type +'/' + fileObj.name,
                    success : function(response){
                        if(response == 'image')
                        { 
                            var images = $('<img src="'+base_url + 'csv/' +fileObj.name+'" alt=""/>');
                            $(images).hide().insertBefore('#displayFiles_pdf').slideDown('slow')
                        }
                        else 
                        {
                            var images = $('<img class="uploaded_images pull-left" src="'+base_url + 'uploads/' +fileObj.name+'" alt=""/>');
                            $(images).hide().insertBefore('#displayFiles_pdf').slideDown('slow')
                        }
                    }
                }); 
            }
            var counter = 0;
            if($("#uploaded_files_names_photo_audio").val().length == 0) {
                images_name=fileObj.name;
                $('#uploaded_files_names_photo_audio').val(images_name);
            }
            else {
                images_name=$("#uploaded_files_names_photo_audio").val()+''+","+fileObj.name;
            }
            $("#uploaded_files_names_photo_audio").val(images_name);
            images_name= '';

        }
    });

我已经尝试过警告vortex.js中的一些随机文本以及uploadify.php中的回显。但是,它显示“HTTP”错误。 请让我知道我应该尝试什么,这将有效吗? 提前谢谢......

0 个答案:

没有答案