Saturday, 14 July 2012

Allow users to download file from your site

I was recently asked to provide a download link to allow users of my website to download a file (a word document).

After an initial Google it seemed that this was going to be a lot more complicated than I thought, but in reality the solution is incredibly simple!

  1. Within your website, create a folder (e.g. named downloads) where you will keep the files that users can download.
  2. Within your webpage (or ASP.NET page) add a simple anchor tag (that's the <a>... </a> you usually use for links.
  3. Set the href property to the location of the file to download.
It's that simple - so you should end up with a tag like:

<a href="../Downloads/documentToDownload.doc">Click here to download file!</a>

Clicking this in your page instead of linking to a page will simply start downloading the file in your browser - easy!

No comments:

Post a Comment

Android Studio - How to change app icon (ic_launcher)

Changing your applications icon (ic_launcher) is a common occurrence when developing your android application. Here's quick steps on how...