Search code examples
htmlfile-upload

how to upload a file to my server using html


Basically, I have this form that allows user to upload to my server:

<form id = "uploadbanner" method = "post" action = "#">
      <input id = "fileupload" type = "file" />
      <input type = "submit" value = "submit" id = "submit" />
</form>

But the problem is that when I choose a file, then click submit, I don't see the file uploaded in the server directory.


Solution

  • <form id="uploadbanner" enctype="multipart/form-data" method="post" action="#">
       <input id="fileupload" name="myfile" type="file" />
       <input type="submit" value="submit" id="submit" />
    </form>
    

    To upload a file, it is essential to set enctype="multipart/form-data" on your form

    You need that form type and then some php to process the file :)

    You should probably check out Uploadify if you want something very customisable out of the box.