Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery AjaxFileupload仅在我的本地主机上工作_Jquery_Ajax_Codeigniter_File Upload - Fatal编程技术网

Jquery AjaxFileupload仅在我的本地主机上工作

Jquery AjaxFileupload仅在我的本地主机上工作,jquery,ajax,codeigniter,file-upload,Jquery,Ajax,Codeigniter,File Upload,这是我的控制器: function upload() { //init var $status = ""; $msg = ""; $file = ""; $config = array( 'upload_path' => './uploads/product_images/full/', 'allowed_types' => 'gif|jpg|jpeg|png', 'max_size' =>

这是我的控制器:

function upload()
{
    //init var
    $status = "";
    $msg = "";
    $file = "";

    $config = array(
        'upload_path' => './uploads/product_images/full/',
        'allowed_types' => 'gif|jpg|jpeg|png',
        'max_size' => '1024',
        'encrypt_name' => true,
        'remove_spaces' => true
    );
    $this->load->library('upload', $config);

    if (! $this->upload->do_upload('file'))
    {
        $status = 'Error';
        $msg = $this->upload->display_errors('', '');
    }
    else
    {
        $uploaded = $this->upload->data();
        $this->load->library('image_lib');

        //resize ori image to large image
        $config['image_library'] = 'gd2';
        $config['source_image'] = './uploads/product_images/full/'.$uploaded['file_name'];
        $config['new_image'] = './uploads/product_images/large/'.$uploaded['file_name'];
        $config['maintain_ratio'] = true;
        $config['width'] = 400;
        $config['height'] = 400;
        $this->image_lib->initialize($config);
        $this->image_lib->resize();
        $this->image_lib->clear();

        //resize large image to small image
        $config['image_library'] = 'gd2';
        $config['source_image'] = './uploads/product_images/large/'.$uploaded['file_name'];
        $config['new_image'] = './uploads/product_images/small/'.$uploaded['file_name'];
        $config['maintain_ratio'] = true;
        $config['width'] = 180;
        $config['height'] = 200;
        $this->image_lib->initialize($config);
        $this->image_lib->resize();
        $this->image_lib->clear();

        //resize large image to thumb image
        $config['image_library'] = 'gd2';
        $config['source_image'] = './uploads/product_images/small/'.$uploaded['file_name'];
        $config['new_image'] = './uploads/product_images/thumb/'.$uploaded['file_name'];
        $config['maintain_ratio'] = true;
        $config['width'] = 80;
        $config['height'] = 80;
        $this->image_lib->initialize($config);
        $this->image_lib->resize();
        $this->image_lib->clear();

        $status = "Success";
        $msg = "File successfully uploaded";
        $file = $uploaded['file_name'];
    }
    echo json_encode(array('status' => $status, 'msg' => $msg, 'file' => $file));
}
还有我的js:

$('#upload-btn').on("click",function(e){
e.preventDefault();
$('.loading').show();

var files = $('#img_list');
var url = 'http://sukukhek.com/admin/products/upload/';

$.ajaxFileUpload
({
    url: url,
    secureuri: false,
    fileElementId: 'file',
    dataType: 'json',
    success : function (data, status)
    {
        if(data.status == 'Error')
        {
            $('#feedback').html('<div class="alert-box alert-error"><a class="close-box">x</a>'+data.msg+'</div><br>');
            $('.loading').fadeOut('fast');
        }
        else
        {
            $('#feedback').html('<div class="alert-box alert-success"><a class="close-box">x</a>'+data.msg+'</div><br>');
            $('#title').val('');
            $('#caption').val('');
            refresh_files(data.file);
        }
    }
});

return false;
});

function refresh_files(data)
{
    var p = data.split('.'),
        id = p[0],
        filename = p[0]+'.'+p[1],
        path = 'http://sukukhek.com/uploads/product_images/small/';
    var photo = 'some long html code';
    $('#img_list').append(photo);
}
$(“#上传btn”)。在(“单击”上,函数(e){
e、 预防默认值();
$('.loading').show();
var文件=$(“#img_列表”);
var url='1〕http://sukukhek.com/admin/products/upload/';
$.ajaxFileUpload
({
url:url,
secureuri:false,
fileElementId:'文件',
数据类型:“json”,
成功:功能(数据、状态)
{
如果(data.status=='Error')
{
$('#feedback').html('x'+data.msg+'
'); $('.loading').fadeOut('fast'); } 其他的 { $('#feedback').html('x'+data.msg+'
'); $('#title').val(''); $('标题').val(''); 刷新_文件(data.file); } } }); 返回false; }); 函数刷新\u文件(数据) { var p=data.split('.'), id=p[0], filename=p[0]+'.+p[1], 路径http://sukukhek.com/uploads/product_images/small/'; var photo='一些长html代码'; $('img#u list')。追加(照片); }
在localhost上,这段代码工作得很好,但是当我上传到服务器上的public_html时,文件上传到了upload目录,但是回调函数不起作用,加载div仍然出现,新的图像也没有出现

附加信息:

当file upload为空时,数据类型为:json,发送错误消息成功,但当选择file to upload时,上传,但回调函数失败

更新:

在chrome的“网络”选项卡上,如果要上载的文件存在,我会收到此消息

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  escapeshellarg() has been disabled for security reasons</p>
<p>Filename: libraries/Upload.php</p>
<p>Line Number: 1066</p>

</div>{"status":"Success","msg":"File successfully uploaded","file":"5ea47dfe50826f573b65b63f46190a05.jpg"}

遇到一个PHP错误
严重性:警告

消息:出于安全原因,已禁用escapeshellarg()

文件名:libraries/Upload.php

电话号码:1066

{“状态”:“成功”,“消息”:“文件已成功上载”,“文件”:“5ea47dfe50826f573b65b63f46190a05.jpg”}
$(文档).ready(函数(){

$('#photoimg').live('change',function(){
$(“#预览”).html(“”);
$(“#预览”).html(“”);
$(“#imageform”).ajaxForm({
目标:“#预览”
}).submit();
});
}); 

首先尝试使用您最喜欢的开发工具中的“网络”选项卡对其进行调试。我做到了,网络选项卡中没有错误,状态为POST 200 OK。服务器返回的结果是否为预期结果?首先,它显示此handleerror Uncaught TypeError:对象函数(e,t){返回新的b.fn.init(e,t,r)}没有方法“handleerror”。但根据这一点,我在底部添加了一些代码,错误消失了。你能帮我解决这个问题吗:(可能是服务器的平台与您的本地不同,我的意思是您可能使用windows作为本地计算机,linux计算机作为服务器。这一次/和\很重要。
        $('#photoimg').live('change', function()            { 
                   $("#preview").html('');
            $("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
        $("#imageform").ajaxForm({
                    target: '#preview'
    }).submit();

        });
    });