0

Jquery function (it is working):

del_selected.on('click', function(e){

    box.filter(':checked').each(function(){
        selektovane_slike.push($(this).val());
        $(this).parent().slideUp('fast');
    });
    data = JSON.stringify(box.serialize(), null, 2);
    console.log(data);
    $.post(del_url, data, function(){

    }, JSON);
    e.preventDefault();
});

This function gives this result:

"slike=apples.jpg&slike=50BestBandLogos.jpg&slike=Great-Logos-200x200.jpg"

And in PHP we have this:

function ypg_delete_img_selected()
{
    print_r($_POST);
}

Response which I get is:

Disallowed Key Characters.

What is the problem?

HTML:

<div class="zuta_strana_trenutne_slike">
                            <p>All Images</p>
                            <?php $imgs = explode(',', $zts['image']);
                                foreach($imgs as $img) : ?>
                            <div class="zuta_strana_izmena_slika">
                                <img src="<?php echo IMG ?>zute_strane/thumbs/<?php echo $img ?>" title="<?php echo $zts['name'] ?>" />
                                <input type="checkbox" name="slike" value="<?php echo $img  ?>" />
                                <a href="<?php echo base_url() ?>zute_strane/ypg_delete_img/<?php echo $img . '/' . $zts['id_global_info'] ?>" title="<?php echo $img ?>">Obriši Sliku</a>
                            </div>
                            <?php endforeach; ?>
                            <a class="zute_strane_izmena_selektuj_sve">Select All</a>
                            <a href="<?php echo base_url() ?>zute_strane/ypg_delete_img_selected/<?php echo $zts['id_global_info'] ?>" class="zute_strane_izmena_obrisi_sve">Delete Selected</a>
                        </div>
Sasha
  • 8,521
  • 23
  • 91
  • 174
  • something in the data is not allowed. Check out the data which is being passed in the backend. what jquery version are you using ? – insomiac Oct 12 '12 at 18:39
  • I am using 1.8.2, and data which is passed is this: **"slike=apples.jpg&slike=50BestBandLogos.jpg&slike=Great-Logos-200x200.jpg"** – Sasha Oct 12 '12 at 18:40
  • can you provide you elements here?? Also take a look into this post : http://stackoverflow.com/questions/4197976/codeigniter-disallowed-key-characters – insomiac Oct 12 '12 at 18:44
  • What elements? I have looked at the post, used suggested answer, but still nothing. – Sasha Oct 12 '12 at 18:52
  • provide your HTML ELEMENTS... ex : .. etc – insomiac Oct 12 '12 at 18:52
  • shouldn't your checkboxes be slike[]? wouldn't you just be overwriting each sllike and end up with just the last one? – Kai Qing Oct 12 '12 at 18:59
  • I tried that way and nothing, error message is unchanged. I guess I need to find some other way to solve this. – Sasha Oct 12 '12 at 19:01
  • Well, it wasn't a solution as much as a general observation about your markup. When you do resolve this, not specifying the checkboxes as an array will become another problem. – Kai Qing Oct 12 '12 at 19:50

2 Answers2

1

You need to update your allowed characters in application/config/config.php:

$config['permitted_uri_chars'] = 'a-z 0-9~%\.\:_\+-,?&=';

obviously modify that to suit your needs.

Kai Qing
  • 18,793
  • 5
  • 39
  • 57
  • Still nothing (I looked at the code and added & as permitted character) – Sasha Oct 12 '12 at 18:42
  • can you update yoru answer with your actual config line? you need to add and escape . as well. Also = and & – Kai Qing Oct 12 '12 at 18:43
  • For the moment config is **$config['permitted_uri_chars'] = 'a-z 0-9~%\.\:_\+-,?&=';** and I am adding characters to see which one is needed. – Sasha Oct 12 '12 at 18:47
  • Escape? 'a-z 0-9~%\.\:_\+\-\,\?\&\=' – dakdad Oct 12 '12 at 18:48
  • This function is trolling me. I put **'a-zA-Z 0-9~%\.\:_\+\-\,\?\&\=\"'** and still nothing. – Sasha Oct 12 '12 at 18:51
  • Well, you only need to escape characters that are operators in regex. ., -, etc. I'm testing this locally and it doesnt give me a disallowed error for anything by default. maybe i'm just plain wrong. – Kai Qing Oct 12 '12 at 18:56
  • Some crazy gremlins found a way to get into my code. I guess I will have to find another way to do this. – Sasha Oct 12 '12 at 18:59
  • you can test to see if this is even your issue by just leaving this field blank and retrying it. If it gets rid of your problem you know it is an issue with your provided url. – Will Sampson Oct 12 '12 at 20:03
0

Relate an id to each image on the server and deal with ids instead of arbitrary file names. The way you are currently doing this is going to lead to a lot of headaches.

Jordan Arsenault
  • 7,100
  • 8
  • 53
  • 96
  • We tried both methods (id and image name), and the method where you name images as a text string in one table cell seems to work a bit faster (for updating and deleting purpose) than to create table row for every image. We are still trying it, but I think we gonna keep this method. – Sasha Oct 13 '12 at 11:00