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 8666007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:37:25+00:00 2026-06-12T17:37:25+00:00

I have been looking at that same code for two hours now and I

  • 0

I have been looking at that same code for two hours now and I can’t figure out what the problem is. It has to be something silly, because I get an undefined index error, but I just don’t see it.
Please, give it some fresh eyes!

The actual error:

Notice: Undefined index: paper_attach in
[redacted]
on line 104

Notice: Undefined index: paper_attach in
[redacted]
on line 105 Error: No file uploaded

THE HTML:

    <label for="paper_attach">Attach the paper:</label> <input type="file" name"paper_attach" class="paper_metadata"><br />
       <label class="textarea" for="comments">Comments:</label><br /> <textarea name="comments"><?php if (isset($comments)) { echo $comments;} ?></textarea><br /><br />

    <input type="submit" value="Save">

</form>

The PHP:

//Сheck that we have a file
        if(!empty($_FILES['paper_attach'])) {
            //Check if the file is pdf, doc or docx and it's size is less than 20MB
            $filename = basename($_FILES['paper_attach']['name']);
            $ext = substr($filename, strrpos($filename, '.') + 1);

            if ((($ext == "pdf") && ($_FILES["paper_attach"]["type"] == "application/pdf")) or  (($ext == "doc") && ($_FILES["paper_attach"]["type"] == "application/msword")) or (($ext == "docx") && ($_FILES["paper_attach"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")) 
                && ($_FILES["paper_attach"]["size"] < 20000000)) {
                //Determine the path to which we want to save this file
                $attachment_url = 'uploads/'.$filename;
                //Check if the file with the same name already exists on the server
                if (!file_exists($attachment_url)) {
                    //Attempt to move the uploaded file to it's new place
                    if ((move_uploaded_file($_FILES['paper_attach']['tmp_name'],$attachment_url))) {
                        echo "It's done! The file has been saved as: ".$attachment_url;

                        // ** VALIDATIONS PENDING
                        $query = "SELECT [redacted]";
                        if ($query_run = mysql_query($query)) {
                            $query_num_rows = mysql_num_rows($query_run);
                            assert($query_num_rows<= 1);

                            if ($query_num_rows === 0) {
                                // There's no row with this pmid, so we can add it
                                $query = "INSERT [redacted]";

                                if ($query_run = mysql_query($query)) {
                                    header('Location: success.php');
                                }

                            } elseif ($query_num_rows === 1) {
                                echo 'There already is a paper with the PMID: '.$pmid.' in the database.';

                            }
                        }

                    } else {
                        echo "Error: A problem occurred during file upload!";
                    }

                } else {
                    echo "Error: File ".$_FILES["paper_attach"]["name"]." already exists";
                }
            } else {
                echo "Error: Only .doc, .docx or .pdf files under 20MB are accepted for upload.";
            }

        } else {
            echo $_FILES['paper_attach'];
            echo "Error: No file uploaded <br />".$_FILES['paper_attach']['error'];

        }
  • 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-12T17:37:27+00:00Added an answer on June 12, 2026 at 5:37 pm

    You forgot the = on your <input type="file"> should be:

    <input type="file" name="paper_attach" class="paper_metadata" />
    

    instead of your

    <input type="file" name"paper_attach" class="paper_metadata">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking into packages that would enable me to have tabs in
I have been looking around for a visualization framework that would aid graph visualization
I have been looking into libraries for a file system that will allow path
I've been looking at a lot of iOS user interfaces that have been customized.
Basically, I am using Wireshark looking at captures that have been created previously. How
I've been looking around for quite a while and feel that I have a
I've been looking at the code in this tutorial , and I found that
I have been looking at this code and I'm confused about the rep cmpsb
I have been assigned a project with a lot of poorly written code that
I have been trying to make a script that compares two images in HTML5

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.