Jump to content

Recommended Posts

you need to check the MIME type or $_FILES['type'] variable, create an array to hold the allowed types and then you can compare the upload against the array. there are additional checks you can perform, but this is the most basic.

 

Here is a basic tutorial i found:

http://php.about.com/od/advancedphp/ss/php_file_upload_2.htm

 

Here is a link for MIME types:

http://www.ltsw.se/knbase/internet/mime.htp

somethink like this ok.

 

<?php 
$target = "upload/"; 
$target = $target . basename( $_FILES['uploaded']['name']) ; 

$_FILES['type']=array(".jpg",".png",".gif");

foreach($_FILES['type'] as $wanted_file_type){

if(!$wanted_file_type){

echo "sorry you must only use the following file type <br> .jpg <br>
.png <br> .gif <br> please try agin";
}
}
$ok=1; 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} 
else {
echo "Sorry, there was a problem uploading your file.";
}
?> 

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.