Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!