duanlei2458 2017-05-17 08:28
浏览 63

从wp media wordpress上传图像时,用户将被注销

I have a website where user can register and update their profile info. Subscriber user role assigned to them. For updating image i am using wp media uploader. When a subscriber user upload their profile image using and choose file locally, it show me error

An error occurred in the upload. Please try again later.

And if i refresh page, it logged out the user.

The same procedure if followed by admin user then everything works fine.

Here is the code for the image uploading:

 <i class="fa fa-cloud-upload" ></i>
 <input class="criteria-file button" id="your_image_url_button" type="button" value="Upload File"/>
 <script>

                                var image_custom_uploader_file;

                                var $thisItem = '';



                                jQuery(document).on('click','.criteria-file', function(e) {

                                    e.preventDefault();



                                    $thisItem = jQuery(this);



                                    //If the uploader object has already been created, reopen the dialog

                                    if (image_custom_uploader) {

                                        image_custom_uploader.open();

                                        return;

                                    }



                                    //Extend the wp.media object

                                    image_custom_uploader_file = wp.media.frames.file_frame = wp.media({

                                        title: 'Choose File',

                                        button: {

                                            text: 'Choose File'

                                        },

                                        multiple: false

                                    });



                                    //When a file is selected, grab the URL and set it as the text field's value

                                    image_custom_uploader_file.on('select', function() {

                                        attachment = image_custom_uploader_file.state().get('selection').first().toJSON();

                                        var url = '';

                                        url = attachment['url'];

                                        var filename ='';

                                        filename = attachment['filename'];

                                        $thisItem.parent().parent().parent().find('.criteria-image-url').val(url);

                                        $thisItem.parent().parent().parent().find('.criteria-image-url-name').val(filename);

                                        $thisItem.parent().parent().parent().find('.file-name').val(filename);

                                        $thisItem.parent().parent().parent().find('.criteria-file').css("display", "none");

                                        $thisItem.parent().parent().parent().find('.criteria-file-remove').css("display", "block");

                                        $thisItem.parent().parent().parent().find(".fa-cloud-upload").css("display", "none");

                                        $thisItem.parent().parent().parent().find(".fa-trash-o").css("display", "block");

                                    });



                                    //Open the uploader dialog

                                    image_custom_uploader_file.open();

                                 });



                                 jQuery(document).on('click','.criteria-file-remove', function(e) {

                                    jQuery(this).parent().parent().parent().find('.criteria-image-url').val('');

                                    jQuery(this).parent().parent().parent().find('.criteria-image-url-name').val('');

                                    jQuery(this).parent().parent().parent().find('.file-name').val('');

                                    jQuery(this).parent().parent().parent().find('.criteria-file').css("display", "block");

                                    jQuery(this).parent().parent().parent().find(".fa-cloud-upload").css("display", "block");

                                    jQuery(this).parent().parent().parent().find(".fa-trash-o").css("display", "none");

                                    jQuery(this).css("display", "none");

                                 });

                            </script>

I tried to increase define( 'WP_MEMORY_LIMIT', '512M' ); but didn't work.

Anyone can suggest me how i can fix this issue.

Thanks in Advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法