• 0

[PHP] Set exe to auto download


Question

Hey,

Making a website for where i work, and there is a .exe file that we need people to download.

its a file that lets us set up a remote connection to their PC, so it really needs to stay as a exe file as well, because these people are stupid.

I've got some PHP code that i thought would make it download when you click a link, but it seems to download the php file instead.

i dont really understand how this auto download thing works, so if someone knows how to make this work, i would appreciate the help :D

<?php
header('Content-disposition: attachment; filename:DLA-Remote-Support.exe');
header('Content-type: application/octet-stream');
readfile('DLA-Remote-Support.exe');
?>

Thanks in advance

Im an idiot!

PHP isnt always the best solution. Some times you just gotta stick with good ol' HTML :D

Link to comment
https://www.neowin.net/forum/topic/905538-php-set-exe-to-auto-download/
Share on other sites

8 answers to this question

Recommended Posts

  • 0
  On 29/05/2010 at 14:20, DomZ said:

What's wrong with just having an <a> href link to the exe?

im such an idiot!

as soon as i read back what i had put, i realised that. was just about to edit my post to say im an idiot :(

was going completely the wrong way about things.

  • 0

Yeh a href is definatly a better idea unless you going to add a counter and tell the person your about to download something onto there computr (yes i know they will get a save dialog) because if i was to load a page and it tried to automatically download something on my computer wihtout warning i would leave the site, delete the download and i may even write a not so nice email.

  • 0
  On 29/05/2010 at 14:33, Xoligy said:

Yeh a href is definatly a better idea unless you going to add a counter and tell the person your about to download something onto there computr (yes i know they will get a save dialog) because if i was to load a page and it tried to automatically download something on my computer wihtout warning i would leave the site, delete the download and i may even write a not so nice email.

Well... in a situation like mine where I do roughly the same thing 30 times a day and 28 out of those 30 times I'm explaining to the person why they should click "Run" on the file i'm telling them to download. It's a hassle... A big one. I'd rather have it download immediately and run itself, especially if it's only being accessed on my corporate intranet.

  • 0
  On 03/06/2010 at 18:45, giantsnyy said:

Well... in a situation like mine where I do roughly the same thing 30 times a day and 28 out of those 30 times I'm explaining to the person why they should click "Run" on the file i'm telling them to download. It's a hassle... A big one. I'd rather have it download immediately and run itself, especially if it's only being accessed on my corporate intranet.

You might do the same thing 30x a day, but if my grandad contacted me and said "im just on xxx website and im being asked to download xxx and ive clicked nothing what should i do?" my response would be "click cancel" Like i said some warning before hand, or a a href link is best i never download anything thats automatic without some warning first would you download a file just because its an automatic download? Even it it is on an intranet does not mean its not a bad file!

  • 0

Hello,

I was searching for some tips for downloading files with php, and I found your forums.

Here is my experience:

When using something like this

&lt;?php
header('Content-disposition: attachment; filename:DLA-Remote-Support.exe');
header('Content-type: application/octet-stream');
readfile('DLA-Remote-Support.exe');
?&gt;

I can download zip and rar files with no problems, but when it comes to exe files, when downloaded, they can't open. I get some error message.

But when using

header("Location: file.exe")

it works well when downloaded. But, there is other problem. If I refresh (probably close too) the page, while downloading, it stops.

So, I still didn't find a perfect solution, I use combination of these two.

DomZ asked what's wrong with ordinary <a> link. It is better to use automatic download with php, 'cause in that case you can record some statistics for downloaded file.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Looks like MS is officially extending Windows 10 support while stopping just short of officially changing the end date. I teased in the last article that the process for gaining free support was a little invasive, but this is basically just giving it out for free, so I guess I'm taking back those words.
    • Microsoft shares Windows 10 ESU key guide for office PCs that don't support Windows 11 by Sayan Sen Recently, the Indian government issued a caution about the upcoming end of support for Windows 10 which is about four months away. Interestingly, on that very day, Microsoft made a major announcement regarding this as the tech giant debuted free enrollment options wherein support would be extended for another year at no extra cost. Microsoft is also trying to make it easy to set up Extended Security Updates (ESU) with a new tool. You can see in the image below: New ESU enroll wizard Following that, today, the company has shared a new guide on how to activate ESU via Intune in the case of Windows 10 office PCs that are not supported on Windows 11. First up, Microsoft has reminded users of the prerequisites of Windows 10 ESU: The system needs to be on Windows 10 22H2 with KB5046613 (November 2024 Patch Tuesday) or newer. The device needs access to the network endpoints required for client activation. The process that is used for activation needs administrative privileges on the device. The guide contains several PowerShell scripts and are meant for IT admins and system admins. One of those is a validation script "Check-Win10ESUPrereq.ps1" that Microsoft has published to help "verify a device has the required version and patch level for Windows and it can communicate to the required network endpoints." Essentially, it checks if the aforementioned requirements are satisfied and can be used for troubleshooting against those prerequisites. After the "validation," Microsoft says there are two ways to proceed with the ESU key activation. First. it can be done by either Remediation through: Detection Script (Win10ESUActivation-detect.ps1) and Remediation Script (Win10ESUActivation-remediate.ps1). And second, by Win32 Application with Win32 Install Script (Win10ESU-install.ps1) and Win32 Detection Script (Win10ESU-detection.ps1). In the case of Remediations, Microsoft mentions "some licensing considerations" due to which "some smaller companies may not have that option." Finally, Microsoft has also shared some Activation IDs for manual verification via Slmgr VB script for obtaining volume activation information: Win10 ESU Year1: f520e45e-7413-4a34-a497-d2765967d094 Win10 ESU Year2: 1043add5-23b1-4afb-9a0f-64343c8f3f8d Win10 ESU Year3: 83d49986-add3-41d7-ba33-87c7bfb5c0fb You can check the full guide and the details here on Microsoft's official Tech Community website.
    • It blows me away how overpriced Synology is. $600+ for a 3+ year old SATA NAS with only gigabit networking!! Even for 2022 that is pretty low-end hardware. Yes, the Synology software is fantastic, but if we say this hardware is worth $300 max (and that is even giving a generous premium to the fact that it is made by a respected OEM), their software is NOT worth an additional $300, especially considering it is locked to the hardware it shipped on and you have to pay that premium again for your next device. Important correction to the specs table above. Saying Disk Capacity is 72TB and even going further to detail that is 4x18, strongly implies it comes with those disks, which it does not. I would rather see it say "Max Capacity: 72TB (disks not included)."
    • well again if w11 adoption its so high there's no reason why they try to explain us why is "better" to move to w11. If they are so right about their downgraded UI, why they add some of their UI elements back things like never combine and now small icons. Last time i check majority is still on 10 over 11 so yeah millions of users that did not upgrade to w11
    • Size 15. In the first week I managed to get a full week before having to recharge from 10%. I looked online and Samsung recommends recharging it when it gets to 20-30% to preserve the battery life. In the second week, started wearing my Galaxy Watch6 Classic again, because I read that it offsets sensors to the Watch, meaning the battery lasts even longer... and a week on (today) the ring was at 31% when I recharged it fully again, so a difference of over 20% in combination with the Watch. By the way I do not wear my Watch to bed, so it is only the Ring doing the sleep tracking (which is hit or miss tbh) it stops tracking for an hour or two in the night, which is really annoying. I had the same thing with the Watch, and I found it uncomfortable to have on in bed. I have been reading that the battery can start to go bad even after the first week so I am glad it isn't affecting me (yet).
  • Recent Achievements

    • Conversation Starter
      Kavin25 earned a badge
      Conversation Starter
    • One Month Later
      Leonard grant earned a badge
      One Month Later
    • Week One Done
      pcdoctorsnet earned a badge
      Week One Done
    • Rising Star
      Phillip0web went up a rank
      Rising Star
    • One Month Later
      Epaminombas earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      529
    2. 2
      ATLien_0
      207
    3. 3
      +FloatingFatMan
      168
    4. 4
      Michael Scrip
      149
    5. 5
      Steven P.
      122
  • Tell a friend

    Love Neowin? Tell a friend!