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? Quote Link to comment 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... Quote Link to comment 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 Quote Link to comment 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 =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.