Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8747271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:19:45+00:00 2026-06-13T12:19:45+00:00

Possible Duplicate: Undefined index: file Hi I’m learning right now how to upload images

  • 0

Possible Duplicate:
Undefined index: file

Hi I’m learning right now how to upload images to database, but I’m getting this error/notice

Notice: Undefined index: image in C:\xampp\htdocs\Pildibaas\index.php on line 19

Here is my index.php whole code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image upload</title>
</head>

<body>
    <form action="index.php" method="POST" enctype="multipart/form-data">
        File:
        <input type="file" name="image"> <input type="submit" value="Upload"> 
    </form>


<?php
mysql_connect ("localhost", "root", "") or die (mysql_error());
mysql_select_db ("databaseimage") or die (mysql_error());


?>
</body>

</html>

Line 19 (this line gives error) cut out from index.php:

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

From google found that i need to change premission of tmp folder, but it allready shoud have all premissions it needs.

In tutorial he dont get this error

thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:19:46+00:00Added an answer on June 13, 2026 at 12:19 pm
    echo $file = $_FILES['image']['tmp_name'];
    

    should be

    if(isset($_FILES['image'])){
        echo $_FILES['image']['tmp_name'];
    }
    

    This checks first if $_FILES['image'] is set. If not, this wil not be run. Therefore, you will not have an error that it is out of index.

    Because you first have to submit the form before $_FILES['image'] will be set…

    Also, the input tag is self closing, so your form will not be:

    <form action="index.php" method="POST" enctype="multipart/form-data">
        File:
        <input type="file" name="image"> <input type="submit" value="Upload"> 
    </form>
    

    but:

    <form action="index.php" method="POST" enctype="multipart/form-data">
        File:
        <input type="file" name="image" /> <input type="submit" value="Upload" /> 
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” This is strange but
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” This code shows warnings
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I am just learning
Possible Duplicate: Undefined reference - C++ linker error Now, I'm getting an Undefined reference
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index i am getting ranksection
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” I am getting warnings.
Possible Duplicate: Why am I getting Undefined index from my PHP? $pattern2 = /([A-Za-z0-9\.\-\_\!\#\$\%\&\'\*\+\/\=\?\^\`\{\|\}]+)\@([A-Za-z0-9.-_]+)(\.[A-Za-z]{2,5})/;
Possible Duplicate: Getting ‘undefined index’ error while trying to use $_FILE in PHP I
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I know its basic
Possible Duplicate: Undefined Behavior and Sequence Points The variable i is changed twice, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.