Jump to content

Warning: getimagesize(): Filename cannot be empty.


FmanTheCoder

Recommended Posts

Im making an only photo sharing website for school and there is an error when it gets teh size of the image that the person selected.

 

Warning: getimagesize(): Filename cannot be empty in C:\xampp\htdocs\index.php on line 21

 

Here is the coding part of it.

if (!isset($file))
   echo "Please Select An Image";
else
{
  $image = file_get_contents($_FILES['image']['tmp_name']);
  $image_name = addslashes($_FILES['image']['name']);
  $image_size = getimagesize($_FILES['images']['tmp_name']);
  if ($image_size==FALSE)
     echo "The Specified File Is Not A Picture.";
  else
  {
    if (!$insert = mysql_query("INSTERT INTO image VALUES ('$image_name', '$image_name', '$image')"))
       echo "Upload Error.";
    else
    {
   $lastid = mysql_insert_id();
   echo "Image Uploaded.<p />Your Image:<p /><img src=get.php>";
    }
  }
}

Im new to php so im not that good. But Thanks!

did you read the error? it is fairly self explanatory, $_FILES['images']['tmp_name'] is empty. is your code checking if the upload worked before trying to use any of the uploaded file information?

$file = $_FILES['image']['tmp_name'];

This is the rest of the code and its before the code above.

 

First the website gets the information, then uploads, then uses it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.