[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

HTML code for automatic file download

Posted on 2013-11-06
11
Medium Priority
?
362 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 84

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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

656 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