clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 well... I'm making a picture uploader that only accepts filenames named "logo.gif"... but there must be something wrong cuz even when I upload a file named logo.gif it gives me the "Filename must be logo" error message. <?php include('../../../config/main.php'); session_start(); $logoFile = basename($_FILES['uploadlogo']['name']); $logoPath = "../../../images/"; $logoFullPath = $logoPath . $logoFile; if (move_uploaded_file($_FILES['uploadlogo']['tmp_name'], $logoFullPath)) { chmod($logoFullPath, 0777); $ext = pathinfo($logoFullPath); if ($ext['basename'] !== "logo.gif") { $_SESSION['cngState'] = "The image MUST be named logo.gif"; Header("Location: $shpUrl"); unlink($logoFullPath); } elseif ($ext['extension'] !== "gif") { $_SESSION['cngState'] = "The file type MUST be gif"; Header("Location: $shpUrl"); unlink($logoFullPath); } elseif ($ext['filename'] !== "logo") { $_SESSION['cngState'] = "The filename MUST be logo"; Header("Location: $shpUrl"); unlink($logoFullPath); } else { $_SESSION['cngState'] = "Your new logo has been succsessfully uploaded."; Header("Location: $shpUrl"); } } ?> Link to comment https://forums.phpfreaks.com/topic/46198-solved-extfilename-messing-up-everything-please-help-me/ Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Author Share Posted April 9, 2007 please... anyone? Link to comment https://forums.phpfreaks.com/topic/46198-solved-extfilename-messing-up-everything-please-help-me/#findComment-224605 Share on other sites More sharing options...
MadTechie Posted April 9, 2007 Share Posted April 9, 2007 try <?php if (strtolower($ext['basename']) != "logo.gif") { $_SESSION['cngState'] = "The image MUST be named logo.gif"; Header("Location: $shpUrl"); unlink($logoFullPath); } ?> Note the !== changed to != also i conveted to lowercase i would also add an echo strtolower($ext['basename']) and comment out the header after just so you can see what your getting Link to comment https://forums.phpfreaks.com/topic/46198-solved-extfilename-messing-up-everything-please-help-me/#findComment-224622 Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Author Share Posted April 9, 2007 roger that... just finishing up this usernam and password changer... started on a project last night... think it's gonna be much harder than I first thought..hehe... Link to comment https://forums.phpfreaks.com/topic/46198-solved-extfilename-messing-up-everything-please-help-me/#findComment-224636 Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Author Share Posted April 9, 2007 it worked perfectly! thanks m8... Link to comment https://forums.phpfreaks.com/topic/46198-solved-extfilename-messing-up-everything-please-help-me/#findComment-224639 Share on other sites More sharing options...
MadTechie Posted April 9, 2007 Share Posted April 9, 2007 as a note you had some other !== in the code you may want to change them to != please click solved Link to comment https://forums.phpfreaks.com/topic/46198-solved-extfilename-messing-up-everything-please-help-me/#findComment-224643 Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Author Share Posted April 9, 2007 i just replaced all of them witht the one you got... cuz I didn't need to check every section of the filename =) all the script needs to know is if the file is named "logo.gif" or not =) hehe... so all the other codes was just waste of time =) Link to comment https://forums.phpfreaks.com/topic/46198-solved-extfilename-messing-up-everything-please-help-me/#findComment-224646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.