Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

download script 1

Status
Not open for further replies.

sikarius

Programmer
Dec 11, 2001
63
ES
Hi everybody (again :) )

I'm working in a script for download any file of the server. My script is:

<?php
global $file;
header('Content-Type: application/octetstream');
header('Content-Disposition: filename=$file');
header('Pragma: no-cache');
header('Expires: 0');
?>

where $file is a parameter in the url like this:


but its doesnt work....

Please someone can give some help ??

Thanks a lot
 
use this instead:
Code:
<?php
header('Content-Type: application/octetstream');
header(&quot;Content-Disposition: attachment; filename=$file&quot;);
header('Pragma: no-cache');
header('Expires: 0');
?>
(-:
 
Thanks a lot for your quickly reply :)

well i try your script and it seems works but i cant display the file (a picture), The size of the file is 2 Kb (the original) but the size of the file copied is 1 Kb... Why ???

Please can you help me??

Thanks a lot..... again ;)
 
I use this code.

<?
header (&quot;Content-Type: application/octet-stream&quot;);
$path=&quot;../../docspdfs&quot;;
header (&quot;Content-Length: &quot;.filesize(&quot;$path/$filename&quot;));
header (&quot;Content-Disposition: attachment; filename=$filename&quot;);
header (&quot;Pragma: no-cache&quot;);
header (&quot;Expires: 0&quot;);
readfile(&quot;$path/$filename&quot;);

?>
Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Thanks a lot Anikin.... the scripts works very well, thanks, thanks, thanks :)...... If i can help you please call me......
 
Anikin i modified the script:

<?
header (&quot;Content-Type: application/octet-stream&quot;);
$path=&quot;../../docspdfs&quot;;
header (&quot;Content-Length: &quot;.filesize(&quot;$path/$filename&quot;));
header (&quot;Content-Disposition: attachment;
filename=$filename&quot;);
header (&quot;Pragma: no-cache&quot;);
header (&quot;Expires: 0&quot;);
header (&quot;Location: $path/$filename&quot;);
?>

its works too ...

Thanks
 
Even with pdf documents?

When you do a Location you change the URL of the the browser. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Well, i dont try with pdf documents. I try with a mp3 file and gif picture.....but i'll try with pdf documents this evening....

Thanks for the advice !!!!!!!
 
Well Anikin You are right !!!! the pdf files the browser open it ....

Thanks a lot for your great help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top