File uploaded successfully, but not listed in uploads folder

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
richarddunnebsc
New php-forum User
New php-forum User
Posts: 6
Joined: Thu Aug 31, 2017 3:48 am

Fri Sep 15, 2017 6:17 am

I am trying to validate an uploaded file. I am validating step by step, etc, mine, size etc. this is the ext code

Code: Select all

$path_parts = pathinfo($file);
			if($path_parts['extension'] != "doc" || $path_parts['extension'] != "docx")
			{
				echo $path_parts['extension'] ."<br>";
				$error[] = "File must be of type doc or docx";
			}
Further in the code in printing error messages.

Code: Select all

echo $path_parts['extension'] ;
displays docx, yet its still executing the error message. No idea why.

chorn
php-forum Active User
php-forum Active User
Posts: 405
Joined: Fri Apr 01, 2016 2:18 am

Mon Sep 18, 2017 12:41 am

it's because of your condition. you ask if the extension is NOT doc OR NOT docx - as long as it can't be both, one of the expression is always true.

Post Reply