clown[NOR] Posted April 8, 2007 Share Posted April 8, 2007 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 More sharing options...
clown[NOR] Posted April 8, 2007 Author Share Posted April 8, 2007 looks like it's the $search string that's messing up here... Link to comment https://forums.phpfreaks.com/topic/46086-solved-match_found-wont-store-the-value/#findComment-223953 Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 um, not sure but try $var = 1 OR 0 ## whatever if ($var == 0) OR if($var == 1) good luck Link to comment https://forums.phpfreaks.com/topic/46086-solved-match_found-wont-store-the-value/#findComment-223957 Share on other sites More sharing options...
clown[NOR] Posted April 8, 2007 Author Share Posted April 8, 2007 i fixed it now... i used the full path like files/filename.jpg not just the folder name =) Link to comment https://forums.phpfreaks.com/topic/46086-solved-match_found-wont-store-the-value/#findComment-223958 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.