Hi,
I'm using PHP 4.3. There is a section of my application in which I'd
like users to be able to download a custom file. The file would be
different for each user, so I was planning on creating it on the fly
when they click "Download". However, I would like to delete the file
from the server a certain period of time after they've downloaded it.
(It's a 3 or 4K file). How can I do this?
Thanks, - Dave 5 1461 la***********@z ipmail.com wrote:
Hi,
I'm using PHP 4.3. There is a section of my application in which I'd
like users to be able to download a custom file. The file would be
different for each user, so I was planning on creating it on the fly
when they click "Download". However, I would like to delete the file
from the server a certain period of time after they've downloaded it.
(It's a 3 or 4K file). How can I do this?
Thanks, - Dave
Hi Dave,
This can be done in several way, but why do you actually create the file?
You can also just give the user the experience there is a file when (s)he
clicks the downloadbutton.
Just let the download-php-script produce the output, just as you do before
writing the file, and deliver that.
If that doesn't work for you for some reason, and you absolutely need to
create a real file, you can do several things to clean them up, the most
easy:
- Create a sheduled job (cron on *nix) that checks all possible files and
check their createdate. If too old, delete.
Alternatively to a sheduled job, you could use an approach that will do this
once every 100 times your function is called that creates the file.
Or every time, but this may get slow if you have a great numbers of files.
Regards,
Erwin Moller la***********@z ipmail.com wrote:
Hi,
I'm using PHP 4.3. There is a section of my application in which I'd
like users to be able to download a custom file. The file would be
different for each user, so I was planning on creating it on the fly
when they click "Download". However, I would like to delete the file
from the server a certain period of time after they've downloaded it.
(It's a 3 or 4K file). How can I do this?
filemtime() could be used for this.
However, if your file is made dynamically, and downloaded only by a specific
user, is there any reason to save it as a file to begin with? With proper
headers and PHP output you can just dynamically create/'fake' the file each
time it is required, without having to save it, track it, and clean it up.
Grtz,
--
Rik Wasmus
I want the users to download a file with an ".html" extension. What
kind of headers would I use to save creating that on a server and have
that downloaded right to the Desktop (or whereever their default save
location is)?
Thanks, -
Rik wrote:
la***********@z ipmail.com wrote:
Hi,
I'm using PHP 4.3. There is a section of my application in which I'd
like users to be able to download a custom file. The file would be
different for each user, so I was planning on creating it on the fly
when they click "Download". However, I would like to delete the file
from the server a certain period of time after they've downloaded it.
(It's a 3 or 4K file). How can I do this?
filemtime() could be used for this.
However, if your file is made dynamically, and downloaded only by a specific
user, is there any reason to save it as a file to begin with? With proper
headers and PHP output you can just dynamically create/'fake' the file each
time it is required, without having to save it, track it, and clean it up.
Grtz,
--
Rik Wasmus
*** la***********@z ipmail.com escribió/wrote (3 Jul 2006 13:41:15 -0700):
I want the users to download a file with an ".html" extension. What
kind of headers would I use to save creating that on a server and have
that downloaded right to the Desktop (or whereever their default save
location is)?
header('Content-Type: text/html');
header('Content-Length:' . filesize(...... ..));
header('Content-Disposition: attachment; filename="..... ......"');
Another option:
header('Content-Type: application/octet-stream');
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
-- la***********@z ipmail.com wrote:
Hi,
I'm using PHP 4.3. There is a section of my application in which I'd
like users to be able to download a custom file. The file would be
different for each user, so I was planning on creating it on the fly
when they click "Download". However, I would like to delete the file
from the server a certain period of time after they've downloaded it.
(It's a 3 or 4K file). How can I do this?
Thanks, - Dave
Think a few have pointed this out, but you don't need to store the
file, something like:
header('Content-Type: text/html');
header('Content-Length:' . filesize(...... ..));
header('Content-Disposition: attachment; filename="..... ......"');
// Display what you want to output
print "Something, Or, Other, just testing, the way this works";
// Output a new line else everything is all on one line.
print "\n";
print "www.whatever.c o.uk";
print "\n";
Obviously the script can be changed for each user using a little php.
I've a collection of useful scripts on a site I put together (nothing
major, just slowly collecting together things i've written over the
years). http://www.opanoid.co.uk/phphelp/
C Wood. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Cherrish Vaidiyan |
last post by:
sir,
I have a small error in Listener configuration.I have two system with
a database in each. I am using Red Hat 9 and Oracle 9i. so i shall
anme the database and system.
system 1 - node2 system 2 - node3
database - apple database - intel
i have installed Oracle on 'node3' by copying the...
|
by: Robert Oschler |
last post by:
I want to have a master table and a detail table. I want the master table
record to be created only if one does not exist already for a given account
ID.
Here is my concern:
Let's say I have several different web pages being viewed by several
different web surfers. The viewing of the web pages triggers the same PHP
code that attempts...
|
by: Ben Jeurissen |
last post by:
Hello,
I have to deal with the following issue in C++:
Two threads are started from the main thread, both capturing images from
a different firewire camera. Both threads take shots of 460800 bytes at
a rate of 30 frames per second. This works fine, without frame loss, and
I can display the two framestreams on screen.
Now I would like...
|
by: Nicholas Sherlock |
last post by:
Hey all,
People on my website register to be allowed access to certain downloads.
I store these files above the document root so that they can't be
accessed by Apache (Only from PHP). I wrote a file serving script which
dumps the correct headers for the download and calls readfile().
I thought everything was going swimmingly until I...
|
by: Rick |
last post by:
I'm sorry for posting this here, but other more relevant groups are a little
too quiet.
Has anyone out there come up with an effective strategy for using VSS with a
development team? IME it is a nightmare trying to manage releases of code.
We need one release to share among developers, one for the QA team, and one
for the live application....
| |
by: KarlM |
last post by:
After reading some articles regarding confuguration data I'm a bit confused.
Where is the right place for storing configuration data?
- XML-files?
- registry?
- INI-files? (from a users point of view, ini-files are more comfortable to
read and edit)
Where should I store user specific config data?
Where should I store machine specific...
|
by: marcin.rzeznicki |
last post by:
Hello everyone
I've got a little problem with choosing the best decoding strategy for
some nasty problem. I have to deal with very large files wich contain
text encoded with various encodings. Their length makes loading
contents of file into memory in single run inappropriate. I solved this
problem by implementing memory mapping using...
|
by: laredotornado |
last post by:
Hi,
I'm using PHP 4.4.4 with Apache 2.2 on LInux. I have been building a
web site, and now a client wants that same site, only he wants all the
graphics substituted with his own. There could potentially be more
clients who want the same site but with custom graphics. What makes
more sense?
1. Maintain a single code base, only have...
|
by: Joey |
last post by:
I have written an app in C#/asp.net 2.0 that is a system built to
handle a large number of scenarios. Part of that system involves
allowing users to download large files. As part of my original design
strategy, I chose to locate these downloads in a directory separate
from the website file structure.
The two primary purposes for this were:...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |