On my website I have 2 separate places for users to upload an image. The first works perfectly. The second doesn't. As far as I can see, they are exactly the same. To test, I used the same image on both, with it working on the first, but not the second. Here is the code from the non-working one:
<?php
include('cn.php');
$name = $_FILES['image']['name'];
$type = $_FILES['image']['type'];
$size = $_FILES['image']['size'];
$temp = $_FILES['image']['tmp_name'];
$error = $_FILES['image']['error'];
echo $name; //Doesnt echo anything
$rand_num = rand(1, 1000000000);
$name = $rand_num . "_" . $name;
echo $name; //Echos just the random number followed by _
if ($error > 0) {
die("Error uploading file! Go back to the <a href='gallery.php'>gallery</a> page and try again.");
} else {
$sql = "INSERT INTO gallery (image) VALUES ('".$name."')"; //Inserts the random number to the database
$query = mysql_query($sql) or die(mysql_error());
echo $sql;
move_uploaded_file($temp, "gallery_pics/$name"); //Doesn't move the file. gallery_pics exists, if that matters
echo "Upload complete! Go back to the <a href='gallery.php'>album</a>.";
}
?>
If someone could please help me out here. I am sure it is something simple, but I have yet to find anything that helped. Thanks!
EDIT: There are two lines above the code that won't show up properly. One starts the php and the other opens the database.