SecurityError: The operation is insecure. Jquery

0

I have a problem with uploading 2 files at a time, it is likely that I will upload them one by one but I can not find the way right now, the HTML code is this:

<div class="contenedor contenedor_padding">
    <form role="form" name="carta_ficheros_formulario" method="post" enctype="multipart/form-data" action="carta_ficheros_formulario_guardar.php">
        <input type="hidden" name="id_ventajas_foto" value="" />

            <label for="imagen">Imagen (352x302px) (el fichero no puede tener acentros ni caracteres especiales)</label>
            <input id="imagen" name="imagen" type="file" style="display:none">
            <div class="input-append">
                <input type="hidden" id="random" name="random" value="{$random}" />
                <input id="photoCover" class="form-control" type="text" onclick="$('input[id=imagen]').click();" placeholder="">
            </div>

        <div class="clear"></div>
        <br />
        <input type="hidden" name="id_ventajas_foto" value="" />
            <label for="fichero">PDF (el fichero no puede tener acentros ni caracteres especiales)</label>
            <input id="fichero" name="fichero" type="file" style="display:none">
            <div class="input-append">
                <input type="hidden" id="random" name="random" value="{$random}" />
                <input id="fichero" class="form-control" type="text" onclick="$('input[id=fichero]').click();" placeholder="">
            </div>
        <div class="clear"></div>


    </form>
        <br />
        <div class="btn btn-info" onclick="javascript:guardar_ficheros();">Enviar</div>
        <div id="rta"></div>
</div>

If you see something weird like '$ random' is that I use php framework called Smarty, here I pass the javascript code

<script type="text/javascript">

$('input[id=imagen]').change(function() {
random = $("#random").val();
var filename = $(this).val().replace(/C:\fakepath\/, '');
console.log(random+filename);
$('#photoCover').val(random+filename);

$('input[id=fichero]').change(function() {
    random = $("#random").val();
    var filename = $(this).val().replace(/C:\fakepath\/, '');
    console.log(random+filename);
    $('#fichero').val(random+filename);
    subir_fichero();
});

// subir_fichero();
});


// console.log($('form')[0][1]);

function subir_fichero(){

$.ajax({
    url: '.file_upload.php',
    type: 'POST',
    data: new FormData($('form')[0]),
    cache: false,
    contentType: false,
    processData: false, 

    success: function(response){
        $("#rta").html(response);


    }
});
}

</script>

(I feel the tabbed wrong but I still do not control well insert the code here), the fact is that when uploading and an image in the '# rta' shows the first, but the second does not, I'm sure something is missing but I still do not find that if someone can help me I would be grateful.

Greetings

    
asked by juank 24.10.2018 в 12:31
source

0 answers