Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHP If user download file fully?

Posted on 2007-07-24
2
Medium Priority
?
329 Views
Last Modified: 2013-12-12
User begins to get a file :
1) can get as by one stream so by the unlimited amount of streams
2) User can continue download the file and script gives him a file by bytes ( or kb ), well and able to give pieces ( for streams ) !  

it is needed to define is a file got fully ONCE ? after download it to forbid getting of this file another time....

My algorithm: to add up the given amount of information for user from all of streams and write to DB ! In the end to check with files this sum ... well and to draw a conclusion to forbid or not ! Here are a few nuances, how to know user pressed STOP ? Maybe did user come to renew download ? Or anew to rock a file ?
0
Comment
Question by:noviceexpert
2 Comments
 
LVL 4

Accepted Solution

by:
cg_medistox earned 2000 total points
ID: 19559774
Here is some information i found on this matter, i persoanally do not know how you do it but i hope this can help in some way

$filename = "the name of my file";
$filePath = "/path/to/download/$filename";
//lets read this file to the user
//open the file for binary reading
$file = fopen($filePath,"rb");
// we build some headers
header("Content-type: application/octet-stream");
header("Content-Disposition: inline; filename=\"$filename\"");
header("Content-length: ".(string)(filesize($filePath)));
while(!feof($file) )// if we haven't got to the End Of file
{
print(fread($file, 1024*8) );//read 8k from the file and send to the user
flush();//force the previous line to send its info
if (connection_status()!=0)//check the connection, if it has ended...
{
fclose($file);//close the file
die();//kill the script
}
}
fclose($file);//close the file
//if we get this far, the file was completely downloaded
//update the database
0
 

Author Comment

by:noviceexpert
ID: 19563514
This script will download only in 1 thread and watch if the full file send to user! I want create a script wich can watch the full send to user with unlimited threads and user can continue download if it crashed.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question