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
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>

 

Link to comment
Share on other sites

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"?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.