Upload Problem II

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Upload Problem II

Post by Joe »

I am having a bit of a problem with my upload code. Everytime I try to upload a file all I get is an error. What I am trying to create is an array with the file extensions which are allowed to be passed to the server. The code works great when I take this array out so I know it has something to do with it. The code for my array go's like:

$array = array("application/vnd.ms-excel", "application/msword", "application/zip", "application/rtf");

if (!in_array($_FILES['imagefile']['type'], $array))
{
echo "An unexpected error has occured. Please view the <A href='help.php'>help file</A> for more information!";
exit;
}

I tried uploading .zip and .rtf with no luck. Any help appreciated!


Joe 8)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe your browser is sending a different type, or not one at all... what does echoing $_FILES['imagefile']['type'] say?
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

I'm pretty sure everything is a tmp file when it is uploaded.
Have you considered doing a substr for the last three letters of the file name after it has been uploaded?
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

what does

Code: Select all

var_dump($_FILES['imagefile']['type']);
print?
Post Reply