0

My html form looks something like this:

 <form action="dins.php" method="get" name="test" enctype="multipart/form-data">
        <table class="formTable" id="programTable">
            <tr>
                <td class="ft_head">Title</td>
                <td><input type="text" size="26px" name="title" id="title" autocomplete="off" /></td>
                <td></td>
            </tr>
            <tr>
                <td class="ft_head">Objective</td>
                <td><textarea width="26px" height="18px" name="obj" id="obj" autocomplete="off"></textarea></td>
                <td></td>
            </tr>
            <tr>
                <td class="ft_head">Theory</td>
                <td><textarea width="26px" height="36px" name="theory" id="theory" autocomplete="off"></textarea></td>
                <td></td>
            </tr>
            <tr>
                <td class="ft_head">Code</td>
                <td><input type="file" width="26px" name="code" id="code" /></textarea></td>
                <td></td>
            </tr>
            <tr>
                <td class="ft_head">Output</td>
                <td><input type="file" width="26px" name="output" id="output" /></td>
                <td></td>
            </tr>
            <tr>
                <td class="ft_head">Conclusion</td>
                <td><textarea width="26px" height="36px"          name="conc" id="conc" autocomplete="off"></textarea></td>
                <td></td>
            </tr>
        </table>
        <input type="submit" value="submit" name="sub" /> 
    <form>

My part php script is this:

if(isset($_GET['title']) && isset($_GET['obj']) && isset($_GET['theory']) &&   
$_FILES['code']['size']>0 && $_FILES['output']['size']>0 && isset($_GET['conc']))

I am getting the following error:

 _Unable to fetch values.PHP Notice: Undefined index: code in    
 E:\Repository\HTML\123\assign_cg\dins.php on line 4_

I tried modifying php.ini for upload_max_size but did not help. I am running WIMP.

1 Answer 1

1

You should change your form method to POST.

You cannot upload files via GET, that is what POST is for.

In case more clarification is really needed, GET is generally used for retrieving data from the server, while POST is for sending data to the server.

Sign up to request clarification or add additional context in comments.

2 Comments

But we do generally use GET to send data to the server, especially with ajax, so I thought may be I could do the same with files.
@check Of course, with every request, regardless of type, data is being transmitted to the server. Wether to use GET or POST largely depends on the result you want to get: POST is used for sending data to the server and not necessarily expecting a response. GET is used for sending a request to the server in expectation of a response to the request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.