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"); } } ?> Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Author Share Posted April 9, 2007 please... anyone? Quote Link to comment 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 Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Author Share Posted April 9, 2007 it worked perfectly! thanks m8... Quote Link to comment 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 Quote Link to comment 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 =) 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.