php takes the local image file and generates the xml file to output the specific idea

  • 2020-06-01 08:44:05
  • OfStack

 
<?php 
$dir="upload/"; 
$dir_res=opendir($dir); 
$fileFormat=array(0=>".jpg",1=>".gif",2=>".png",3=>".bmp"); 
$xmlData = ""; 
$xmlData .= "<photos>\n"; 
while($filen=readdir($dir_res)) 
{ 
for($i=0;$i<count($fileFormat);$i++) 
{ 
if(substr($filen,strpos($filen,"."))==$fileFormat[$i]) 
{ 

$xmlData .= "<item>\n"; 
$xmlData .= "<url>" .$dir.$filen. "</url>\n"; 
$xmlData .= "</item>\n"; 
break ; 
} 
} 
} 
$xmlData .= "</photos>\n"; 
print $xmlData; 
closedir($dir_res); 
?> 

Combined with "AIR app calls camera to take photos and keeps photos in local folder" published by this website, plus socket, one computer can take photos and another computer can display the photos taken.

Related articles: