0

我正在使用 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”错误。请让我知道我应该尝试什么,哪个会起作用?提前致谢...

4

0 回答 0