tags:

views:

30

answers:

2

Hi,

I've made a contact form with an option to upload image. It's in WordPress(my form is a part of a custom plugin I'm making).

Everytime I upload a file, I find $_FILE to be empty.

Here's code of my form.

<table>
<tr>
    <td valign="top">
        <form action="" method="post" enctype="multipart/form-data">            
        <table cellspacing="0" cellpadding="0" bordercolor="#000000" border="0" bgcolor="#ffffff" width="100%">
            <tbody>
                <tr>
                    <td width="100%">
                        <table cellspacing="0" cellpadding="2" border="0" width="100%">
                            <tbody>
                            <tr>
                                <td width="50%" height="35" >Your Name:<span >*</span></td>
                                <td width="50%"><font size="2" face="Arial" color="#000000">
                                    <input type="text" size="20" value="" id="name" name="formAppName"></font>
                                </td>
                            </tr>
                            <tr>
                                <td height="35" >Your Web Address:<span >*</span></td>
                                <td><font size="2" face="Arial" color="#000000">
                                    <input type="text"  size="20" value="" id="webAddress" name="webAddress"></font>
                                </td>
                            </tr>
                            <tr>
                                <td height="35" >E-mail Address:<span >*</span></td>
                                <td><input type="text" size="20" value="" id="email" name="email"></td>
                            </tr>
                            <tr>
                                <td height="35" >Subject title:<span >*</span></td>
                                <td><font size="2" face="Arial" color="#000000">
                                <input type="text"  size="30" value="" id="subjectTitle" name="subjectTitle"></font>
                                </td>
                            </tr>
                            <tr>
                                <td height="35" >Upload Photo:<span >*</span></td>
                                <td><font size="2" face="Arial" color="#000000">
                                <input type="file" size="25" id="formAppPhoto" name="formAppPhoto"></font>
                                </td>
                            </tr>
                            <tr>
                              <td  colspan="2">Body Text:<span >*</span></td>
                              </tr>
                            <tr>
                                <td colspan="2">
                                    <textarea  rows="25" cols="65" name="bodyText"></textarea>
                                </td>
                            </tr>                           
                            <tr>
                              <td colspan="2">&nbsp;</td>
                            </tr>
                            <tr><td colspan="2"><input type="submit" value="Submit" name="Submit"></td></tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
        <input type="hidden" name="formAppDo" value="45645645" />
        <input type="hidden" name="formAppId" value="98" />
        </form>
    </td>
</tr>

A: 

First of all, action is missing from your form (it's empty). Also, you need to post what you have done in your PHP script.

Anax
if action is empty browser send post request for the same url like the page. yes we need the php code to inspect this
Dobiatowski
Guys, I am able to get all the data from $_POST variable.I'm still writing the PHP code in which the $_FILE variable is empty.I tried var_dump(), and it gave out - NULL
KPL
have you checked your php.ini maybe you have turned off fileupload or maybe you try to send too big file
Dobiatowski
+3  A: 

For reference, it's $_FILES, not $_FILE.

cHao
That was the error! Thanks a lot. :-) Silly me!
KPL
lol, hhahahh :]
Dobiatowski