slaterino Posted August 5, 2008 Share Posted August 5, 2008 Hi, Hopefully there's a quick answer to this issue. The filenames that I'm currently creating for the album images in my gallery are ending with an extra full stop. For example, the name could X78GUB832..jpg. I'm currently having some problems with my gallery in Firefox and want to rule this out as a problem. Below is my code for the page that this is on. Can anyone tell me why the extra full stop is being produced? ///// <?php require_once '../library/config.php'; require_once '../library/functions.php'; if(isset($_POST['txtName'])) { $albumName = $_POST['txtName']; $albumDesc = $_POST['mtxDesc']; $imgName = $_FILES['fleImage']['name']; $tmpName = $_FILES['fleImage']['tmp_name']; $ext = strrchr($imgName, "."); $newName = strtolower(md5(rand() * time()) . ".$ext"); $imgPath = ALBUM_IMG_DIR . $newName; $result = createThumbnail($tmpName, $imgPath, THUMBNAIL_WIDTH); if (!$result) { echo "Error uploading file"; exit; } if (!get_magic_quotes_gpc()) { $albumName = addslashes($albumName); $albumDesc = addslashes($albumDesc); } $query = "INSERT INTO tbl_album (al_name, al_description, al_image, al_date) VALUES ('$albumName', '$albumDesc', '$newName', NOW())"; mysql_query($query) or die('Error, add album failed : ' . mysql_error()); echo "<script>window.location.href='index.php?page=list-album';</script>"; exit; } ?> ///// Thanks! Russ Link to comment https://forums.phpfreaks.com/topic/118318-slight-problem-with-naming-files-in-php-gallery/ Share on other sites More sharing options...
MatthewJ Posted August 5, 2008 Share Posted August 5, 2008 Try removing the . in front of $ext in this line... it looks like the strrchr() function is going to return .jpg on its own $newName = strtolower(md5(rand() * time()) . ".$ext"); Link to comment https://forums.phpfreaks.com/topic/118318-slight-problem-with-naming-files-in-php-gallery/#findComment-608870 Share on other sites More sharing options...
slaterino Posted August 5, 2008 Author Share Posted August 5, 2008 cheers man, now sorted! thanks for your help! russ Link to comment https://forums.phpfreaks.com/topic/118318-slight-problem-with-naming-files-in-php-gallery/#findComment-608939 Share on other sites More sharing options...
akitchin Posted August 5, 2008 Share Posted August 5, 2008 for the record, it's because the character that strrchr() uses as its delimiter is returned with the string to its right. just in case you ever go to use the function again. Link to comment https://forums.phpfreaks.com/topic/118318-slight-problem-with-naming-files-in-php-gallery/#findComment-608946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.