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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:02:38+00:00 2026-05-13T22:02:38+00:00

I swear this script worked fine last night but can’t get it to work

  • 0

I swear this script worked fine last night but can’t get it to work today. It’s not getting inside of the foreach loop though and i don’t know why. the $_FILES array is null even if i select a file and click submit.

Basically this script has a file input tag and using jquery, if a user selects a file, it adds another file input tag. When the submit button is clicked, the PHP is called.

<?php
//used for firePHP
include('PHP/FirePHPCore/fb.php');
ob_start();


$success = false;
$error = "";
$allowable_types = array(
    'image/jpeg',
    'image/pjpeg',
    'image/jpg',
    'image/jpe',
    'image/gif',
    'image/png'
);



#################################################################
//NOT GETTING INSIDE THE FOREACH LOOP. $_FILES array is always null
##################################################################
//loops through the files that the user has chosen to be uploaded them and moves them to the Images/uploaded folder
foreach($_FILES as $key => $value) {
    if(!empty($_FILES[$key])) {
        if($_FILES[$key]['error'] == 0) {
            if(in_array($_FILES[$key]['type'], $allowable_types) && ($_FILES[$key]['size'] < 5000000)) {
                if(!file_exists("Images/uploaded/".$_FILES[$key]['name'])) {
                    move_uploaded_file($_FILES[$key]['tmp_name'], "Images/uploaded/".$_FILES[$key]['name']);
                    $success = true;
                } else {
                    $error = "<h3 class=\"bad\">At least one of the files already exists</h3>";
                }
            } else {
                $error = "<h3 class=\"bad\">At least one of the files you've selected is either too large or not the correct file type</h3>";
            }
        } elseif($_FILES[$key]['error'] == 4) { 

        } else {
            $error = "<h3 class=\"bad\">An error occurred while trying to upload one of the files</h3>";
        }
    } else {
        $error = "<h3 class=\"bad\">You need to select a file</h3>";
    } 
}



?>


<!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" />
<meta http-equiv="refresh" content="1205">
<link rel="stylesheet" type="text/css" href="CSS/reset.css" />
<link rel="stylesheet" type="text/css" href="CSS/uploadFile.css" />
<link rel="stylesheet" type="text/css" href="CSS/galleria.css" />
<script type="text/ecmascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="JS/galleria.jquery.js"></script>

<script type="text/javascript"> 


    $(document).ready(function() { 

        var i = 1;

        //gives the first li the class .active so that it shows the large version as if it's been clicked. 
        //-- used for the gallery page
        $('#content ul.gallery li:first-child').addClass('active');

        //fades the links on hover -- used for the nav links
        $('#header ul li a').hover(function() {
            $(this).fadeTo(300, 0.3);
        },function() {
            $(this).fadeTo(300, 1);
        });



            $('input:file:last').live('change',function() {
                var file = $(this).val();
                if(file !== null && file !== "") {
                    if(i < 6) {
                        $(this).after("<input type=\"file\" name=\"uploadedFile"+i+"\" value=\"\" />");
                        i++;
                    }
                }
            });
    }); 
</script>
<meta name="keywords" content="Steph Mcclisch Photography Portfolio Pictures" />
<title>Steph McClish Photography</title>
</head>

<body>
<div id="floater"></div>
<div id="wrapper">

    <div id="content">
        <?php 
        if($success) {
        echo "<h3 class=\"good\">Files Uploaded Successfully!</h3>";
        } elseif ($error) {
        echo $error;
        }
    ?>
        <h4>Choose the files to be uploaded</h4>
        <form action="<?php $_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
            <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
            <input type="file" name="uploadedFile0" value="" />
            <button type="submit" name="login">Submit</button>
        </form>
        <h5><a href="PHP/Manage.php">Manage Files/Folders</a></h5>
    </div>


</div>
</body>
</html>
  • 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-05-13T22:02:38+00:00Added an answer on May 13, 2026 at 10:02 pm

    It all had to do with my Wamp server setup. On the wamp icon in the menu bar i went php>php settings>file uploads. Just clicked that once and it fixed everything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.