doubledee Posted February 22, 2012 Share Posted February 22, 2012 Is there a way to look for a File without needing the Extension?? If I have the File... someUserPicture.jpg ...and I have the string "someUserPicture", is there a way to use file_exists() and get it to work properly? Thanks, Debbie Quote Link to comment Share on other sites More sharing options...
xyph Posted February 22, 2012 Share Posted February 22, 2012 https://www.google.com/?q=php+match+partial+filename Quote Link to comment Share on other sites More sharing options...
requinix Posted February 22, 2012 Share Posted February 22, 2012 There are a number of false positives in there... Pay attention to the ones involving glob(). Quote Link to comment Share on other sites More sharing options...
skwap Posted February 22, 2012 Share Posted February 22, 2012 Refer the php stristr() function to match the string with another string. Quote Link to comment Share on other sites More sharing options...
doubledee Posted February 22, 2012 Author Share Posted February 22, 2012 There are a number of false positives in there... Pay attention to the ones involving glob(). Have any better ideas then? Here is a snippet of my code... // ******************** // Hash New Image. * // ******************** $newFilename = sha1_file($tempFile); if (!$newFilename){ // Hashing Failed. $_SESSION['resultsCode'] = 'UPLOAD_HASH_IMAGE_FAILED_2119'; // Redirect to Outcome Page. header("Location: " . BASE_URL . "members/results.php"); // End script. exit(); } // ************************ // Create New File Path. * // ************************ $newFilePath = WEB_ROOT . 'uploads/' . $newFilename; // ************************ // Check New File Exist. * // ************************ if (file_exists(WEB_ROOT . 'uploads/' . 'f21190299a795e9cf3439f7f62c223f79e023ab7.jpg')){ echo 'TRUE'; exit(); } // ******************** // Create New Image. * // ******************** // New File to have same File-Type as Original File. switch ($imageType){ case 'image/gif': $newThumbnail = @imagegif($newImage, $newFilePath . '.gif'); break; case 'image/jpeg': $newThumbnail = @imagejpeg($newImage, $newFilePath . '.jpg'); break; case 'image/png': $newThumbnail = @imagepng($newImage, $newFilePath . '.png'); break; default: $newThumbnail = FALSE; } I am trying to see if a Photo already exists based on the Filename BEFORE the Extension, because after I have calculated the appropriate Extension, then a NEW Photo has been generated. I create the "Filename" regardless, because I'll need that when I run an UPDATE on the User's Record. (I'm sure there is a better overall way to do this, but it is my first attempt at things. Hope that makes sense?! Thanks, Debbie Quote Link to comment Share on other sites More sharing options...
xyph Posted February 22, 2012 Share Posted February 22, 2012 Since I've never ACTUALLY SEEN you get it, only ramble and argue about helpful answers you asked for.... glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob Quote Link to comment Share on other sites More sharing options...
doubledee Posted February 22, 2012 Author Share Posted February 22, 2012 Since I've never ACTUALLY SEEN you get it, only ramble and argue about helpful answers you asked for.... glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob glob If you find reading my threads so painful, then why do you bother?? Debbie Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 22, 2012 Share Posted February 22, 2012 http://hungred.com/how-to/php-check-remote-email-url-image-link-exist/ this is most certainly an interesting read for what you are asking of course Quote Link to comment Share on other sites More sharing options...
litebearer Posted February 22, 2012 Share Posted February 22, 2012 Actually, this is NOT necessarily true. I am trying to see if a Photo already exists based on the Filename BEFORE the Extension, because after I have calculated the appropriate Extension, then a NEW Photo has been generated. It is quite easy to create a new name for a file/image BEFORE you actually create/save/rename the file/image. AND as we all know 12345.jpg and 12345.png are considered to be a completely different files. 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.