Image upload script not working?

I keep getting the error : Please only use image files

Heres my code

[php]$name = $_POST[‘name’];
$madeby = $_POST[‘madeby’];
$submitted = $_POST[‘submitted’];
$filedunder = $_POST[‘filedunder’];
$filedunder2 = $filedunder.‘img’;
$Image = $_FILES[‘Image’];
$directoryName = “$baseurl/images/$filedunder”;

$extension = strtolower(pathinfo($Image[‘name’], PATHINFO_EXTENSION));
if (!in_array($extension, array(‘jpg’, ‘jpeg’, ‘gif’, ‘png’))) {
die(“Statement here”);
}

if (!file_exists($directoryName)) { mkdir($directoryName, 0777); }
$directoryName2 = “$baseurl/images/$filedunder”;
if (!file_exists($directoryName2)) { mkdir($directoryName2, 0777); }

if (strpos($_FILE[‘Image’][‘type’], ‘image/’) !== 0) { die(" Please only use image files"); }

if ((!$name) OR (!$filedunder) OR (!$Image))
{
die(“Please dont leave blank info”);}
else
{ mysql_query(“INSERT INTO $filedunder2 (madeby,name,date,submitted) VALUES (’$madeby’,’$name’,’$timestamp’,’$submitted’)”);

                            $insert_id = mysql_insert_id();   
            $image = $insert_id . "img.png";

mysql_query("UPDATE $filedunder2 SET url = ‘$baseurl/images/$filedunder/$image’ WHERE id = ‘$insert_id’ ");
$file = $_FILES[‘Image’][‘tmp_name’];
$dest = $_SERVER[‘DOCUMENT_ROOT’].’/images/’.$filedunder.’/’.$insert_id.‘img.png’;
copy($file, $dest);
die("oooohhhhh It Added!


Take note of this url, as Your uploads page is currently down!!!


www.spardel.com/images/$filedunder/$image
");
}[/php]

$timestamp and $baseurl are both undefined (from what I can see), and we need your upload form

Baseurl and timestamp are in my addon.php

[php]$baseurl = “http://www.spardel.com/”; and $timestamp = $date-64775; [/php]

and my upload form is

[php]

<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
Upload An Image
Made By: ">
You are?: ">
Name of Graphic:
Filed Under: Avatar Background Banner Blinkie Button Gallery Layout Glitter Guide Image Guild Layout Miscellaneous NeoBoard Help Pet Lookup PetPage Layout Shield Shop Layout Tutorial Image User Lookup
Upload Image:
[/php]

What I really do not understand is why you would post this on two different forums (if that’s even all) all you are going to do it get two sets of advice and confuse yourself in the process I suggest you either stick with this forum or go back to php freaks

Sponsor our Newsletter | Privacy Policy | Terms of Service