Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

268
Visualizações
Remove file from server Summernote v0.8.18

I am trying to delete file from server in summernote, but always getting undefined src error.

I searched around found this: Summernote - Delete image from server and more but none of them are working.

I tried var src = $(this).attr("src"); and .prop() function no luck to pass url in src to php file.

This is how src url is :<img src="http://localhost/news/uploads/large/6dBUlfZZBW.webp"> Here is my setup :

   $('#summernote').summernote({
      height: 400,
      callbacks: {
         onImageUpload: function(files, editor, welEditable) {
            sendFile(files[0], editor, welEditable);
         },
         onMediaDelete : function($target) {
             console.log($target[0].src); //This adds full url of src into console on test.

            deleteFile($target[0].src);
            $target.remove();
         }
      }
   });

And my delete function :

function deleteFile(src) {
   var src = $(this).attr("src");
   $.ajax({     
      data:src,
      type: "POST",
      url: "delete_summernote.php",
      cache: false,
      success: function(resp) {
         console.log(resp);
         console.log(src);
      }
   });
}

Simple php example :

if(isset($_FILES['src'])){
$url = $_FILES['src'];

        unlink($url);
        
} else {
   echo "Src not set.";
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Your delete file function has some wrong specifications so that is the reason it is not working. Correct If I am wrong!

var src = $(this).attr("src"); // you are specifying to select "src" attribute

But here : deleteFile($target[0].src); you are selecting source in function then variable src output will be underfined.

This is what I understand. I hope it will help if I am not wrong But I have tried it on my pc. But I don't have full code I could help you.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda