Location: PHPKode > projects > Wiki Web Help > wwh/handlers/uploadimage.php
<?php

$image= $_FILES["imagefile"]['name'];

$isimage = FALSE;
$whitelist = array(".png", ".gif", ".jpg", ".jpeg");
foreach ($whitelist as $item) {
   if(preg_match("/$item\$/i", $image)) {
   	   $isimage = TRUE;
       break;
   }
}

if($isimage == FALSE) exit;

if($image<>""){

$target_path = "../images/";

$target_path = $target_path . basename( $_FILES['imagefile']['name']); 

    if(move_uploaded_file($_FILES['imagefile']['tmp_name'], $target_path)) {

    } else{
    	echo "{'response':'Error uploading image, please try again'}";
    	exit;
    }

}else{
	echo "{'response':'No image file'}";
	exit;
}

echo "{'response':'ok'}";
?>






	
Return current item: Wiki Web Help