0){ //output echo "{\"status\":\"" . $result . "\", \"message\":\"" . $message . "\"}"; exit(); } }//POST method ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// //GET requests with a deviceId should output all the images in the directory. //This JSON output is used to power an Image Gallery Screen. if(strtoupper($reqMethod) == "GET" && strlen($deviceId) > 0){ //start the JSON output $JSON = "{\"childItems\":["; //loop all the files in this directory and add image files to the JSON if(is_dir($imageDirPath)){ if($handle = opendir($imageDirPath)){ while (false !== ($file = readdir($handle))) { if(strlen($file) > 5){ //image files must end with .jpg, .jpgeg or .png $ext = substr(strrchr($file, '.'), 1); //get rid of invalid returns in file name $file = str_replace("\n\r", "", $file); $file = str_replace("\n", "", $file); $file = str_replace("\r", "", $file); if(strtoupper($ext) == "JPG" || strtoupper($ext) == "JPEG" || strtoupper($ext) == "PNG"){ $JSON .= "\n{\"itemId\":\"" . strtoupper(fnCreateGuid()) . "\","; $JSON .= "\"itemType\":\"BT_imageItem\", "; $JSON .= "\"imageName\":\"" . $file . "\","; $JSON .= "\"imageURL\":\"" . $urlToThisDirectory . "/" . $file . "\"},"; } } } } } //remove the comma after last image so JSON is valid $JSON = trim($JSON); if(substr(strtoupper($JSON), (strlen($JSON) - 1), 1) == ","){ $JSON = substr($JSON, 0, strlen($JSON) - 1); } //end the JSON $JSON .= "\n]}"; //print the output echo $JSON; exit(); }//GET method ///////////////////////////////////////////////////////////////////////////////////////////////////////// /*############################################################################################################ The HTML form below will only show if the deviceId variable is empty. The form is desiged to allow you to test the script using your regular browser. ############################################################################################################## */ ?>
Use this page to test the web-server that handles your image uploads.
If your PHP enabled web-server is setup properly and allows file uploads (the folder is writeable) you will see each image you upload in a list.
5){
//image files must end with .jpg, .jpgeg or .png
$ext = substr(strrchr($file, '.'), 1);
if(strtoupper($ext) == "JPG" || strtoupper($ext) == "JPEG" || strtoupper($ext) == "PNG"){
echo "
";
}
}
}
}
}
?>