HI
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
HI
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
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.
Thanks diafol, thread can be closed
OK, please press the blue 'Mark Question Solved' button below the editor.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.