Blazce Zeno
Blazce Zeno

Reputation: 45

check if an image broken

I am testing an image hosting script but there is one issue,when I drag and drop the image to my webpage, it's uploading, but when I hit the F5/refresh button the unfinished image is hosted to my folder,how can I check if an image is broken using php or send a jquery (XHR) request to the php file to stop the upload?

Upvotes: 1

Views: 216

Answers (1)

Arun Killu
Arun Killu

Reputation: 14233

$("img")
  .error(function(){
   alert('error loading image');
  })
  .attr("src", "missing.png");//fallback image

with php you can actually save filesize() in database(during upload) and checking it with size of file in folder(before u display) will give great help.

Upvotes: 1

Related Questions