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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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