Solved

HTML code for automatic file download

Posted on 2013-11-06
11
354 Views
Last Modified: 2013-11-20
have a small piece of code with a hyperlink --- On click  --- downloads the file

<html>
<title>Company Name </title>
<body>
<a href="filepath\filename.ext”>Click here</a>
<body>
</html>

Objective to eliminate a click to download the file.
I wish the download automatically starts
Can anyone help please

Using javascript it is achievable using --- drawback is that it prompts a warning in IE saying Active X

Is there a way to open the link using html script itself.
0
Comment
Question by:MOQINFRA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39629497
Not a good idea. normaly sites that try and automate downloads are downloading viruses or malware, at the very least something they dont want the user to have the choice of refusing.

you will loose more visitors doing this than you will please
0
 

Author Comment

by:MOQINFRA
ID: 39629508
It is an intranet site
0
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39629515
does your intranet have access to the web?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:QuinnDex
ID: 39629517
if it was my intranet and i found a way of allowing it, i would then want to stop it so files couldnt be downloaded to my network from other sites without at least user interaction.

couldnt you load the files from the server rather than through a web page
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39629558
Security restrictions in browsers prevent automatic downloads so people can't 'automatically' download viruses and malware on to your computer.  And just because it is an 'intranet' site does not mean that some of your users won't have bad files.
0
 

Author Comment

by:MOQINFRA
ID: 39629683
still if i need this , is there any modification we can make to the code for this functionality
0
 
LVL 7

Accepted Solution

by:
dimmergeek earned 500 total points
ID: 39633962
I have used this script on our Intranet to automatically download shortcuts to a person's desktop as well as their own partition on a network drive.  I give the user a confirmation box that confirms they want the file. We only use IE here, so this is an ActiveX solution.

// Make shortcuts on user's desktop
function makeLinks()
{
    var WshShell;
    var oShellLink;
    
    // AMRC Home Page
    WshShell = new ActiveXObject("WScript.Shell");
    strDesktop = WshShell.SpecialFolders("Desktop");
    oShellLink = WshShell.CreateShortcut(strDesktop + "\\AMRC Homepage.lnk");
    oShellLink.TargetPath = "file://G:\\AMRC\\AMRC_HOMEPAGE\\AMRC_HOMEPAGE.htm";
    oShellLink.WindowStyle = 1;
    oShellLink.Description = "AMRC Homepage";
    oShellLink.WorkingDirectory = strDesktop;
    oShellLink.IconLocation = "G://BR//AMRC.bmp";
    oShellLink.Save();
}

// Make shortcuts on user's F: drive
function makeFLinks()
{
    // Save shortcuts to F: drive
    var oShell = new ActiveXObject("Scripting.FileSystemObject");
    
    if (! oShell.FolderExists("F:\Shortcuts"))
    {
        oShell.CreateFolder("F:\Shortcuts");
    }
        
    // AMRC Home Page
    WshShell = new ActiveXObject("WScript.Shell");    
    oShellLink = WshShell.CreateShortcut("F:\\Shortcuts\\AMRC Homepage.lnk");
    oShellLink.TargetPath = "file://G:\\AMRC\\AMRC_HOMEPAGE\\AMRC_HOMEPAGE.htm";
    oShellLink.WindowStyle = 1;
    oShellLink.Description = "AMRC Homepage";
    oShellLink.WorkingDirectory = "F:\\Shortcuts\\";
    oShellLink.IconLocation = "G://BR//AMRC.bmp";
    oShellLink.Save();
}

Open in new window

0
 

Author Comment

by:MOQINFRA
ID: 39638780
Thanks
0
 
LVL 7

Expert Comment

by:dimmergeek
ID: 39639160
Was the code helpful?
0
 

Author Comment

by:MOQINFRA
ID: 39658470
I gave it to developer to check , he hasn't responded now.
0
 
LVL 7

Expert Comment

by:dimmergeek
ID: 39662524
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question