Tuskony Posted October 15, 2008 Share Posted October 15, 2008 Hey guys, I tried doing a search but I couldn't find the answer I need. I have a problem! I have a home based Linux web server running Redhat 8.0. I have a small website and I want to allow users to upload up 3 pictures 2 megabytes or less. Page1.php is the page that has the form who's action calls "page2.php". Page1 has 3 "file" fields of which users can pic the pictures they want to upload. Now when the users clicked the submit button on the form they are taken to page2.php. I can't seem to get page2 to use the $_FILES super-global properly! Each file field on page1.php is called "Pic1", "Pic2" and "Pic3" respectively! On page2.php I do this.... $_FILES['Pic1']['name'] and I get nothing even though the Pic1 field on page1.php is filled in with "C:\my pictures\picture 1.jpg". I tried also using pear and HTTP_Upload() which throws me the old "No file chosen for uploading" error or whatever it is. I'm kind of stuck because I have done searches on the web and throughout my PHP books and it appears I'm doing everything correctly yet the form doesn't seem to be passing the files to the 2nd page correctly? Now another funny error that I have is that when I have the form like this: <form action="page2.php" name="NewTruck" method="post" enctype="multipart/form-data"> with the enctype in there the page2 doesn't even load. It tells me I can't connect to that page. However if I removed the enctype the page2.php load but I get the errors as if I haven't submitted a valid file for uploading. Does anyone have any ideas? Quote Link to comment Share on other sites More sharing options...
grim1208 Posted October 15, 2008 Share Posted October 15, 2008 easy fix? try having id="upload" in your form tag ... Quote Link to comment Share on other sites More sharing options...
Tuskony Posted October 15, 2008 Author Share Posted October 15, 2008 Hmmm I still get the "Internet explorer cannot display this page" error. When I have my enctype in there and when I remove that tag the page loads but: echo "pic1 = " . $_FILES['Pic1']['name']; still produces a blank string. Quote Link to comment Share on other sites More sharing options...
iversonm Posted October 15, 2008 Share Posted October 15, 2008 can you post your code? Quote Link to comment Share on other sites More sharing options...
Tuskony Posted October 15, 2008 Author Share Posted October 15, 2008 here is page1.php (the form!) I shortened it up a bit to make it clear.... <form action="page2.php" name="NewTruck" method="post" id="upload"> <table style="width: 100%" cellspacing="0"> <table style="width: 100%" cellspacing="0"> <tr> <td colspan="2" style="background-color: #008000; color: #FFFFFF; font-weight: bold;"> MyTruck Pictures: </td> </tr> </table> <table style="width: 100%" cellspacing="0"> <tr> <td style="width: 125px; background-color: #99ff99; color: #808080;"> Picture 1: </td> <td style="background-color: #ccffcc; color: #666666; font-size: x-small;"> <input type="file" name="Pic1" id="Pic1" value="Browse"> </td> </tr> </table> <table style="width: 100%" cellspacing="0"> <tr> <td colspan="2" style="background-color: #CCFF99; color: #FFFFFF; font-weight: bold;" align="center"> <input type="submit" value="Create MyTruck" id="CreateTruck" name="CreateTruck"> </td> </tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
Tuskony Posted October 15, 2008 Author Share Posted October 15, 2008 page2.php I am simply doing.... echo "Pic1 name = " . $_FILES['Pic1']['name']; which results in "Pic1 name = " The pic1 field on the form being submitted is c:\pics\pic1.jpg. So shouldn't the code on page 2 output "Pic1 Name = pic1.jpg"? Quote Link to comment Share on other sites More sharing options...
Stooney Posted October 15, 2008 Share Posted October 15, 2008 Read this. You're missing enctype for starters. Read through that and you should be able to fix your problem. http://us3.php.net/features.file-upload Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.