I am not a PHP programmer, I am UI developer, I am making a site, there is a form mentioning some links:
I want to do if user click on that link the save window should come up on screen and user should save that file into their place.
for that I want a PHP script, if any 1 have that script plz. plz. help me out in this…
u dont need to write code to download zip,pdf,docx,xls,… files.
u only need to write file path in href of anchor tag.
e.g. <a href=‘test.zip’>Download file</a>
if user click on the above link the save window will come up.
With this, you would need to name the script something.php and when you click on the something.php link, you would then download the something.doc.
You may be able to figure a way to rewrite this to automate the task, but when I first was given this, I manually created the short php file for every file I had ready to be downloaded.
Download an attachment in PHP is pretty simple. Just use the following lines of code in a separate PHP file, say download.php.
<?php
/*Actual filename = 'attachment.zip' (Unknown to the viewers).
When downloaded to be saved as 'mydownload.zip'.
*/
$filename='mydownload.zip';
@header("Content-type: application/zip");
@header("Content-Disposition: attachment; filename=$filename");
echo file_get_contents('attachment.zip');
?>
Now whenever you open this file on your browser window a download dialog box will appear asking whether you want to save the file ‘mydownload.zip’.