473,796 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4277
someusernameher e 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=ra ndom_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:
someusernameher e 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=ra ndom_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_c ontents($filena me)) (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
10212
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 based on queries and creates a pdf, and it works great. My problem is, if i make a change to the data in the database, then rerun that exact pdf routine (done by clicking a form button that reposts the data), the pdf that is refreshed in the...
3
3908
by: Rajiv Das | last post by:
VS 2003, XP SP2 ------------------------------------------------------------ DirectoryInfo temporary = new DirectoryInfo( Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)); FileInfo files = temporary.GetFiles(); foreach(FileInfo fi in files) { Console.WriteLine(fi.FullName); }
5
4957
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: "c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\testapp\97e6075d\ca93f565\assembly\dl2\d5f616ee\9e1410d4_0348c401" I know it is dynamic, but I want to determine what the current directory is in-code.
7
2307
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 do the further process ie. tells IE to download my desired Word File into the Temporary Internet Files and call an office com object to open it
5
3867
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 how asp.net find's it's compiled files when asking for the same webpage which was complied before. -- Bas Hendriks Technical Specialist PinkRoccade
5
3061
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 me. (I don't use ASP.NET or any web service at all, only windows forms). Here is how I work : I have a solution with 10 projects inside. Each of them is built in a different directory (MyProject/bin/debug for each project). I have then a...
2
17280
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 path using IO.Path.GetTempPath(), but I need to do so from outside the application. I am currently using a web service for this, but this is a less than optimal solution: if the web service is unable to start, I don't get the full error message...
1
2165
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 to /bin. However when we do this we get a configuration error. When we copy the DLLs to "/Temporary ASP.NET Files/..." everything works. Does anyone know what could be the reason that the DLLs can be loaded from the temporary files but not from...
5
3429
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 afterwards. I did no development for a couple of weeks, came back and I kept receiving Access Denied to Microsoft.Net\Temporary Internet Files\... Access is Denied. ASPNET had full access to that file and all subfolders. The website I am...
0
9683
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9529
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9054
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7550
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5443
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2927
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.