简体   繁体   中英

How to check if URL is blob or a link in php

How to check if a image src have a blob URL or simple URL in php

Edit

You can simply say that how to check if a object in img src is blob or not?

You can do it before using it in the image source.

Firstly take out the link from the line SRC using regex or using DomDocument like following:
$html = ''; $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXPath($doc); $src = $xpath->evaluate("string(//img/@src)");
Then use parse_html to check if there is host and path in the url. If the parse_html results in false then the link could be stored and check for proper files using file_put_content .

You can use file_exists to check if it is a file.

if( file_exists( $url ) ) ){
  // it is a file
} 
else{
  // it is a blob
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM