I'm trying to learn how I need to upload a file and I am wondering if I have to use

<form method=post> </form>

or can I use

<form method=get> </form>

and why.

Thanks in advance

4 Years
Discussion Span
Last Post by diafol

As a rule of thumb, if you're using a form to store data (or a file) you'd use POST, but if you're just using it to retrieve data (as in a search form), you'd use GET.

For uploading files, you'll also need to ensure that you have something like this:

<form method="post" enctype="multipart/form-data" action="somefile.php">

If you don't set the enctype property to this, then your file upload just won't work. The action property could be left out, in which case you'd be sending the form to the file in which the form resides (sending to itself). Usually we send data to a 'form processing page'. There are pros and cons to both - sending to itself is easier, as you don't need to redirect (header) back to the form, BUT a refresh of the page following form submission can cause the form to submit again.


OK, please press the blue 'Mark Question Solved' button below the editor.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.