<?php
$rn = $_GET['rn'];
$file_exts = array("jpg", "jpeg", "png");
$upload_exts = end(explode(".", $rn));
#$images/$rn
if (in_array($upload_exts, $file_exts)) {
#if (in_array(file_exists($haystack), $needle) {
if (array_search($upload_exts, $file_exts/*file_exists("c:/xampp\htdocs\php/images/" .*/)) {
$str_img = str_replace(' ', '_', $rn);
} else {
$str_img = 'thumb.png';
}
}
echo $str_img;
?>
Okay so I have this code, but I can't get the result I'm looking for.
I want to see if a file exist, using array_*
and other functions like file_exists
.
What my problem is, when I want to add a new file type, I will just type it in the array
field, and it will search for it, if an image/file was found, the file name + file type will be printed out
e.g google-img.jpg
, else it whould print thumb.png
.