I don't know if this is the right forum because I'm not sure if the problem is in the php script or the html page. I wrote an html form to upload both regular form data (name, date, email etc.) and to upload 2 photographs. To test if they were populating the $_FILES variable I wrote a little test in php in the test.php page The first time I tested it everything was fine. The php returned info for both the $_GET and the $_FILES displayed the info I expected. However, when I ran it the second time to double check it I got the response below. line 267 form action = test.php line 310 image1 input (using a browse button) line 316 image 2 input " line 383 php code that was in test.php line 399 Browser response Any help or insight is appreciated. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <link rel="stylesheet" href="main.css" /> <script type="text/javascript" src="javascript/bw-menu.js"></script> <title>Photograph Submission Page | North Country Camera Club</title> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <header> <br> <p id="nccc"><span>North Country Camera Club</span><br> <i>Member of the New England Camera Club Council</i></p> </header> <article id="submissionPage"> <p style="clear: both"></p> <h1>Photo Submission Page</h1> <p style="padding-left: 50px; font-size: 1.2em; text-align: center; font-style: italic;">Please use the form below to upload your photos for an upcoming camera club competition.</p> <p>Required fields are marked with <span class="frmRqd">*</span> and a red background. </p> <form enctype="multipart/form-data" class="inputForm" id="upLoadForm" method="post" action="test.php"> <input type="hidden" name="MAX_FILE_SIZE" value="600000" /> <fieldset id="photographerInfo"> <legend style="font-size: 1.4em;"><strong><b>Photographer Information</b></strong></legend><br> <p> <label for="firstname"><b>First Name <span class="frmRqd">*</span></b></label> <input name="firstName[]" type="text" class="text" id="firstName" tabindex="100" autocomplete="on" placeholder="First Name" required autofocus> <label for="lastName"><b>Last Name <span class="frmRqd">*</span></b></label> <input name="lastName[]" type="text" class="text" id="lastName" tabindex="100" autocomplete="on" placeholder="Last Name" required > </p> <p> Please enter your password</p> <p> <label for="password"><b>Password <span class="frmRqd">*</span> </b></label> <input name="password[]" type="password" class="text" id="password" tabindex="100" autocomplete="off" placeholder="Password" required > </p> <p style="padding-left: 50px;">Please enter your email and phone numbers so we may contact you if there is a problem with your upload.</p> <p> <label for="email"><b>Email</b><span class="frmRqd">*</span></label> <input name="email[]" type="email" class="text" id="email" tabindex="110" autocomplete="on" placeholder="Your email address" required > </p> <p> <label for="phone"><b>Phone<span class="frmRqd">*</span></b> </label> <input name="phone[]" type="tel" class="text" id="phone" tabindex="130" autocomplete="on" placeholder="(123)456-7890" required> </p> <p style="padding-left: 50px;">Please enter the competition date in the Year-Month format <b> YYYY-MM</b>.</p> <p style="padding-left: 50px;"> Competition Date<p> <p> <label for="month"><b>Competition Month<span class="frmRqd">*</span></b></label> <input name="comp_mo[]" type="text" class="text" id="comp_mo" size="2" tabindex="135" autocomplete="off" placeholder="MM" required > <label for="year"><b>Competition Year<span class="frmRqd">*</span></b></label> <input name="comp_yr[]" type="text" class="text" id="comp_yr" size="4" tabindex="140" autocomplete="off" placeholder="YYYY" required > </p> <p style="padding-left: 50px;">You may enter two digital images per comptetition. Please use the fields below to upload your images. Remember, the file names must be in the following format:<i> Imagename-yourFirstNameYourLastName.jpg. </i> Spaces and special characters are not permitted. Images must be <b>jpg</b> images <i>no larger than 1024 x 800 pixels</i>. Files may not exceed 500 Kb. <i>Please try to keep them as small</i> as possible as larger files will slow load times for the web site. If your files exceed this size and you are unsure of how to reduce their size and maintain the image quality please visit this <a href="tutorials.htm">tutorial.</a> </p> <p> <label for="UploadImg1"><b>Image 1 <span class="frmRqd">*</span></b></label> <input id="uploadImage1" value="pic1[]" type="file" class="image" id="pic1" tabindex="150" Placeholder="Your First Image File" required /> </p> <p> <label for="UploadImg2"><b>Image 2</b></label> <input id="uploadImage2" value="pic2[]" type="file" class="image" id="pic2" tabindex="160" Placeholder="Your Second Image File" /> </p> <br> <p style="padding-left: 75px;"> <input type="submit" value="Submit"/> </p> </fieldset> </form> </article> <script type="text/javascript" src="../javascript/jquery-1.9.0.min.js"></script> <script type="text/javascript" src=".../javascript/forms.js"></script> <script type="text/javascript" src="../javascript/webform2_src.js"></script> <footer id="pageFooter"> <p><a href="index.htm">Home</a> | <a href="forsale.htm">Equipment</a> | <a href="news.htm">News</a> | <a href="calendar.htm">Calendar</a> | <a href="photo_gallery/photo_gallery.htm">Photo Gallery</a> | <a href="information_links/information_links.htm">Links</a> | <a href="Rules/Rules.htm">Rules</a> | <a href="contact.htm">Contact</a></p> <p id="copyright">All Photographs are copyrighted by the photographer. All rights reserved. </p> </footer> <script> $(document).ready (function (){ if(!modernizr.input.autofocus) {$("input[autofocus]").focus(); } }); $(document).ready (function(){ if(!modernizr.input.placeholder){ makePlaceholders(); } } </script> </body> </html> <?php /* // 5. Close Connection if (isset($connection)){ mysql_close($connection); } */ ?> <!-- THIS IS THE CODE FROM THE TEST PAGE--> <?php print_r($_POST); echo "<br>"; if (isset ($_FILES)) { echo "Files is set." , "<br>"; } print_r($_FILES); ?> <!-- THIS IS THE BROWSER RESPONSE Array ( [MAX_FILE_SIZE] => 600000 [firstName] => Array ( [0] => TestFirst ) [lastName] => Array ( [0] => TestLast ) [password] => Array ( [0] => password ) [email] => Array ( [0] => test@test.com ) [phone] => Array ( [0] => 1234567890 ) [comp_mo] => Array ( [0] => 11 ) [comp_yr] => Array ( [0] => 2012 ) ) Files is set. Array ( ) --> Code (markup):
Try ripping out the javascript for nothing jquery asshattery, see if that makes a difference. Of course if you had semantic markup instead of 'let's throw tags with semantic meanings around things for no reason' it might be easier to debug... what with the B for nothing, oddball values and inputs without names, paragraphs around things that are not paragraphs, line breaks doing padding's job, paragraph and I doing H1 and SMALL's job, ARTICLE around a bunch of stuff that isn't an article, a clearing paragraph like it's still 1997, presentational style inlined in the markup, and... well... to be brutally frank the typical garbage I expect from the HTML 5 crowd -- which is to say HTML 3.2 style decade and a half out of date practices that now get's 5 lip-services doctype and a bunch of javascript for nothing instead of the old tranny. WAIT!!! I see your real problem -- you have no NAME attributes on any of your type="file" inputs. I think you have what you meant to use as names as VALUE... no, that's not right either since you've got pic1[] and pic2[] instead of pic[1] and pic[2]... Also probably not helping matters is your FOR attributes on your labels don't match any of the input ID's... and of course if you have to futz around with tabindex there's probably something wrong with your source order. Yeah, none of those [] make any sense, why are you returning EVERY field as a separate array?!? ... and again the HTML 5 garbage attributes are actually ruining the accessibility instead of aiding it... but then I HATE placeholders -- and there's NO REASON to be wasting time on them since you've got perfectly good labels!!! Likewise why waste a paragraph saying "enter your password" when you have the LABEL "password:"?!? But again, your real problem is no NAME attributes on your INPUT[type=file] -- remember NAME is sent server side, ID is for client-side. (No matter what the people still coding like Nyetscape 4 matters try to do with names)
Thank you for the input. I'm new to this - can you tell? I cleaned up the code as you suggested and changed the Name attributes as you suggested and that seems to have been the trick. I also realized that I was using the [] incorrectly. Thanks again.
Just an FYI ... I was just recently working with a form for uploading files and no matter what, $_FILES was empty. A bit of Googling and someone sugested empying the tmp folder on the server. Sure enough, that did it in my case. HTH
Thanks I'll dump the temp folder and see if that causes it to run better. The real problem was the way I was incorrectly using the [] but I will routinely dump the temp folder when using supervariables and maybe I can prevent future similar issues.