Hey guys,
Trying to create a photo gallery with PHP. (I’m a complete novice…)
Here’s some of my index code for the upload form:
[php]
<?php
include('config.php');
}
?>
$result = mysql_query(“SELECT * FROM photos”);
while($row = mysql_fetch_array($result))
{
echo ‘
’;
echo ‘
echo ‘
echo ‘
’;echo ‘
<a href=’.$row[‘location’].’>
echo ‘
’.$row[‘caption’].’
';echo ‘
}
?>
here’s my addexec code:
<?php include('config.php'); if (!isset($_FILES['image']['tmp_name'])) { echo ""; }else{ $file=$_FILES['image']['tmp_name']; $image= addslashes(file_get_contents($_FILES['image']['tmp_name'])); $image_name= addslashes($_FILES['image']['name']); move_uploaded_file($_FILES["image"]["tmp_name"],"photos/" . $_FILES["image"]["name"]); $location="photos/" . $_FILES["image"]["name"]; $caption=$_POST['caption']; $save=mysql_query("INSERT INTO photos (location, caption) VALUES ('$location','$caption')"); header("location: index.php"); exit(); } ?>[/php]What I need help with is creating image upload restrictions, so determining specific file types that can be uploaded and a max file size. then error messages that pop up if file can’t be uploaded!
PLEASE HELP