Re: folder creation in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is what I use to force a download:
  
  header("Pragma: public");
  header("Expires: 0");
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  header("Cache-Control: public"); 
  header("Content-Type: $type");
  header("Content-Disposition: attachment; filename=".basename($dfile).";");
  header("Content-Length: ".filesize($dfile));
  readfile("$dfile");

$type has to be set to the mime-type of the file you are downloading.
$dfile needs to be set to the filesystem path of the file (use
$_SERVER['document_root'] + whatever folder it is in + filename.

The way I like to do it is create a file (download.php) and put this
into it, I also have some error checking in download.php. When I want
a file to be downloaded I link to this file with the get variables
$dfile, $type, and $redir, or get it from a db with an id. Then at the
end of the script use header("Location: $redir");

-ApexEleven[.com]


On Tue, 12 Oct 2004 14:34:06 -0400, Gryffyn, Trevor
<tgryffyn@xxxxxxxxxxxxxxxxx> wrote:
> The browser will automatically do this when you click on a link to a
> file that the web browser knows as a file that you download versus HTML
> or text being sent to the browser where it's just displayed instead of
> triggering the download prompt.
> 
> Maybe that doesn't make much sense.. My head's a bit foggy right now.
> But the deal is, you just need to create a link that when clicked on,
> sends the browser something other than HTML or text or a known picture
> format (you might have to send headers declaring the MIME type too...
> Most likely do).
> 
> The link itself is something that's just done in HTML.  What happens
> when you click the link might be PHP driven, but in general this isn't a
> PHP or DB question unless there's something with the link that you're
> having trouble creating.
> 
> -TG
> 
> 
> 
> > -----Original Message-----
> > From: Adil [mailto:aasheer@xxxxxxxxxxxx]
> > Sent: Tuesday, October 12, 2004 2:28 PM
> > To: php-db@xxxxxxxxxxxxx
> > Subject:  folder creation in php
> >
> >
> > Here's what i'm trying to do in php and a mySQL database:
> >
> > I want a button on a page that if clicked it launches the
> > browser's or OS's
> > "Save As" window, allowing me to specify where to save my
> > file and/or create
> > a new folder
> >
> > thx in advance
> > Adil..
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
<<--------------------------------------------------------
Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
------------------------------------------------------->>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux