Jump to content

[SOLVED] $match_found wont store the value


clown[NOR]

Recommended Posts

i'm currently messing around with file uploading, and i want to check if there's allready a file with the same name so it doesn't overwrite anything... but I couldn't get it to work.. so i diabled the whole upload part and tried to echo out the result...

 

this is the code

<?php
$path = "files/";
$full_path = $path . basename($_FILES['uploadedfile']['name']);
$file = basename($_FILES['uploadedfile']['name']);
$match_found = false;

if (is_dir($full_path)) {
	if ($dh = opendir($full_path)) {
		while (($search = readdir($dh)) !== false) {
			if ($search == $file) { $match_found = $search; }
		}
		closedir($dh);
	}
}

if ($match_found) { echo "Found 1 match! (" . $match_found . ")"; }
elseif (!$match_found) { echo "No match found! (" . $match_found . ")"; }
?>

 

and all it returns to me is:

No match found! ()

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/46086-solved-match_found-wont-store-the-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.