Jump to content

$_FILES not working in form!!!!


Tuskony

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/128481-_files-not-working-in-form/
Share on other sites

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>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.