473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Temporary URL's for download files

Hey, I need to implement this with PHP, i.e. I have some files in
www.myserver.com/files what I need is when an user log into the
account a temporary URL is created for download a file in /files, and
then, when the file is downloaded the link disappear of course, I also
need to know how to protect the files for downloading by direct URL,
make sense?
Jul 28 '08 #1
2 4257
someusernamehere schrieb:
Hey, I need to implement this with PHP, i.e. I have some files in
www.myserver.com/files what I need is when an user log into the
account a temporary URL is created for download a file in /files, and
then, when the file is downloaded the link disappear of course, I also
need to know how to protect the files for downloading by direct URL,
make sense?
No.
Send the file directly with the download-link by a reference or
something like that.
So nothing must bei stored temp.
Create a random numer and store it in a DB with the user id and req.
filename.

create the link like that:
download.php?id=user_id&ran=random_number
Example for download.php:

// select the req filename from db.
// exit, if not found
// else read the file into $dump
// and delete the entry in the DB

// example for CSV file
header("Content-Disposition: attachment; filename=export.csv");
header("Content-Type: text/csv");
echo $dump;
Jul 29 '08 #2
On Jul 29, 11:57 am, Olaf Schinkel <tr...@schinkel.tvwrote:
someusernamehere schrieb:Hey, I need to implement this with PHP, i.e. I have some files in
www.myserver.com/fileswhat I need is when an user log into the
account a temporary URL is created for download a file in /files, and
then, when the file is downloaded the link disappear of course, I also
need to know how to protect the files for downloading by direct URL,
make sense?

No.
Send the file directly with the download-link by a reference or
something like that.
So nothing must bei stored temp.
Create a random numer and store it in a DB with the user id and req.
filename.

create the link like that:
download.php?id=user_id&ran=random_number

Example for download.php:

// select the req filename from db.
// exit, if not found
// else read the file into $dump
// and delete the entry in the DB

// example for CSV file
header("Content-Disposition: attachment; filename=export.csv");
header("Content-Type: text/csv");
echo $dump;
Personally, I'd consider using sha1(file_get_contents($filename)) (or
`sha1 $filename`) as the temporary name rather than a random number
since this might make the most efficient use of a staging area for
temporary files.

C.
Jul 29 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: phpninja | last post by:
Greetings, I was wondering if it is possible to delete someone's temporary internet files with javascript? Basically I'm am using a PDF module called HTML_ToPDF. The pdf module takes some output...
3
by: Rajiv Das | last post by:
VS 2003, XP SP2 ------------------------------------------------------------ DirectoryInfo temporary = new DirectoryInfo( Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));...
5
by: localhost | last post by:
I want to determine within my code-behind only the location of the current tem directory for ym ASP.NET files. For example, the latest web app build on my system shows: ...
7
by: Norton | last post by:
Hi all, I would like to know if there is any method in asp or asp.net to direct the browser to download a file into the Temporary Internet Files directory so that i can make use of vb script to...
5
by: Bas Hendriks | last post by:
Has anyone any idea how asp.net find it's files back after compiling them to the temporary asp.net directory? I found on numerous webpages that the directorynames are chosen random but cannot find...
5
by: Verane | last post by:
Hi, I have read the thread named "Could not copy temporary files to the output directory" on this newsgroup. And I have the same symptoms on my machine. But I didn't find any solution suitable for...
2
by: Rik Hemsley | last post by:
Hi, I am looking for a way to discover the path to the ASP.NET temporary directory, which is called something like 'Temporary ASP.NET Files'. From within an ASP.NET application, I can get the...
1
by: Boris | last post by:
We have some .NET 1.1 DLLs which we want to use in a ASP.NET 1.1 web page (actually one is a real .NET DLL in Managed C++ while the others are native Windows DLLs). First we copied all of the DLLs...
5
by: rogersw8n | last post by:
Some how, some way the account that creates folders under Temporary Internet files has been changed to a domain account for VS 2003 and VS 2005. I recently installed VS 2005. All seemed to be ok...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.