Jump to content

[SOLVED] $ext['filename'] messing up everything... please help me


clown[NOR]

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.