PHP Upload file error: UPLOAD_ERR_EXTENSION

Doing a file upload off a image submited in a form.

receiving this error: UPLOAD_ERR_EXTENSION


function file_upload_error_message($error_code) {
    switch ($error_code) { 
        case UPLOAD_ERR_INI_SIZE: 
            return 'The uploaded file exceeds the upload_max_filesize directive in php.ini'; 
        case UPLOAD_ERR_FORM_SIZE: 
            return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; 
        case UPLOAD_ERR_PARTIAL: 
            return 'The uploaded file was only partially uploaded'; 
        case UPLOAD_ERR_NO_FILE: 
            return 'No file was uploaded'; 
        case UPLOAD_ERR_NO_TMP_DIR: 
            return 'Missing a temporary folder'; 
        case UPLOAD_ERR_CANT_WRITE: 
            return 'Failed to write file to disk'; 
        case UPLOAD_ERR_EXTENSION: 
            return 'File upload stopped by extension'; 
        default: 
            return 'Unknown upload error'; 
    } 
} 



	echo "Upload: " . $_FILES["imgfile"]["name"] . "<br />";
    echo "Type: " . $_FILES["imgfile"]["type"] . "<br />";
    echo "Size: " . ($_FILES["imgfile"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["imgfile"]["tmp_name"] . "<br />";

    if (file_exists("missrock_uploads/" . $_FILES["imgfile"]["name"]))
    {
    	echo $_FILES["imgfile"]["name"] . " already exists. ";
    }else{
      if(move_uploaded_file($_FILES["imgfile"]["tmp_name"],"missrock_uploads/".$_FILES["imgfile"]["name"]))
      {
      	echo "Stored in: " . "missrock_uploads/".$_FILES["imgfile"]["name"]."<br>";	
      }else{
      	echo "There was an error uploading the file ".$_FILES['imgfile']['name'].", please try again!<br><br>";
      	$error_message = file_upload_error_message($_FILES['imgfile']['error']); 
      	echo $error_message;
      }
    }

Open in new window

LVL 5
daniel_smithAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cwiedmannCommented:
From http://php.net/manual/en/features.file-upload.errors.php:

UPLOAD_ERR_EXTENSION
Value: 8; A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help. Introduced in PHP 5.2.0.

What extensions do you have installed?
0
daniel_smithAuthor Commented:
Wish i could tell you, no clue how to tell.
0
cwiedmannCommented:
Create a page with the following code, and look at the output.
<?php
echo phpinfo();

Open in new window

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

daniel_smithAuthor Commented:
i got that, only extenstion i see is PHP

0
cwiedmannCommented:
That seems unlikely.  Most installations would have at least a few extensions.  What do you see as the next sections after "HTTP Headers information" in your phpinfo output?
0
daniel_smithAuthor Commented:
HTTP Request  GET /phpinfo.php HTTP/1.1  
Accept  application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*  
Accept-Language  en-US  
User-Agent  Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)  
Accept-Encoding  gzip, deflate  
Host  www.x-x-x-x-x-x.com  
Connection  Keep-Alive  
Cookie  __utma=202877714.1843906341.1268058660.1270052690.1270056387.13; __utmz=202877714.1268058660.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmc=202877714  
0
cwiedmannCommented:
I'm looking for the sections after the HTTP Headers information section, not the contents of that section.  The following sections should be for the extensions that are installed.
0
daniel_smithAuthor Commented:
bz2
calendar
ctype
curl
date
exif
ftp
gd
gettext
hash
iconv
ldap
libxml
mime_magic
mysql
mysqli
openssl
pcre
PDO
pgsql
session
SimpleXML
sockets
SSL
standard
sysvmsg
tokenizer
wddx
xml
0
cwiedmannCommented:
Nothing jumps out at me in that list.  Do you have access to the web server's error log file?  Can you check in there to see if any of the extensions logged error messages when you uploaded the file?
0
daniel_smithAuthor Commented:
figured it out, folder I was moving the file to had wrong permissions.

CHMOD the folder and it worked. Not the error I expected for that issue tho.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cwiedmannCommented:
Yeah, I would have expected CANT_WRITE in that case too.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.