0

i have a file ( get_photos.php ) normally when i paste the url (http://localhost/web/inc/get_photos.php ) in my browser i think it should display all pictures exist in a directory named ( uploads ) . but unfortunately it display an error:

Notice: Undefined index: bill in C:\xampp\htdocs\innotech\inc\get_photos.php on line 2 File not uploaded successfully.

this is the code of get_photos.php

<?php
    if (is_uploaded_file($_FILES['bill']['tmp_name'])) {
        $uploads_dir = '../uploads/';
        $tmp_name = $_FILES['bill']['tmp_name'];
        $file_name = $_FILES['bill']['name'];
        move_uploaded_file($tmp_name, $uploads_dir.$file_name);

    }else{
       echo "File not uploaded successfully.";
    }

?>

can someone tell me what is "bill" and "tmp_name" means ?? and how i can solve the problem

  • "bill" is your file input tag name. – Dave Apr 10 '18 at 11:14
  • 2
    Please research before asking, this error message gets asked about all the time. https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef – CBroe Apr 10 '18 at 11:15
  • @Dave what it should contain as a code , and where i should put in ??? – stackoverstudent Apr 10 '18 at 11:15
  • 'tmp_name' :: The temporary filename of the file in which the uploaded file was stored on the server. http://php.net/manual/en/features.file-upload.post-method.php – Dave Apr 10 '18 at 11:16
  • @CBroe i searched a lot , but i didn't understand any solution , because every problem is different from my problem – stackoverstudent Apr 10 '18 at 11:17
  • @stackoverstudent : your ** your file tag name – Dave Apr 10 '18 at 11:17
  • _“because every problem is different from my problem”_ - the overall _issue_ is always the same. You are trying to access a value/parameter that _might not_ be set, so you have to properly _check_ beforehand. How to do that, is explained in the duplicate. You really need to get away from this attitude of “this isn’t _exactly_ my problem” and “if it isn’t copy&paste-ready, then I don’t consider it a solution” ... to being able to go read up on stuff and actually _understand_ what is explained there. _That_ is what learning means. – CBroe Apr 10 '18 at 11:24
  • Guys, please read the entire question! @stackoverstudent the code of the page you gave doesn't show (or print) your photos - it's a code to uploads a photo from your form - so basically, the page you have doesn't even do what you except – GRosay Apr 10 '18 at 11:24
  • @PreacherMuffin thank you sir , so this is my problem i misunderstand of how this function work – stackoverstudent Apr 10 '18 at 11:28
  • @CBroe thank you sir for your advice , i will work with it next time – stackoverstudent Apr 10 '18 at 11:28

0 Answers0