PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,491 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,833 people online right now. Registration is fast and FREE... Join Now!




How can i know when download finished?

 

How can i know when download finished?

livium

29 Jun, 2009 - 01:12 PM
Post #1

D.I.C Regular
***

Joined: 21 Dec, 2008
Posts: 294


My Contributions
I have this obvious simple html script for downloading a file:

CODE

<div id="apDiv36"><a href="myfile.rar" ><img src="download.jpg" border="0"> </img> </a> </div>


This script does the following. When I press a picture of a download button, it downloads myfile.rar. So what i want to do is to increment in my database a value which determines how many times a file has been downloaded using the AJAX tehnic. But for that i need to know when the file was completely downloaded by user (using that windows wizard for standard download), so I can increment the value.
I don't want to increment the value if the user had cancelled the download at a specific time.
So how can i found out if the file was completely downloaded?

Thank you!

User is offlineProfile CardPM
+Quote Post


nick1200

RE: How Can I Know When Download Finished?

29 Jun, 2009 - 01:18 PM
Post #2

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions


easy make it so when the link or file has you call it is clicked it adds 1 to the database

a table in the database

so you would need a insert fuctions smile.gif
User is offlineProfile CardPM
+Quote Post

livium

RE: How Can I Know When Download Finished?

29 Jun, 2009 - 01:22 PM
Post #3

D.I.C Regular
***

Joined: 21 Dec, 2008
Posts: 294


My Contributions
QUOTE(nick1200 @ 29 Jun, 2009 - 01:18 PM) *

easy make it so when the link or file has you call it is clicked it adds 1 to the database

a table in the database

so you would need a insert fuctions smile.gif


i don't think you understood my question.

i want the file to be donwloaded completely, and then to insert an incremented value in db.

This post has been edited by livium: 29 Jun, 2009 - 01:22 PM
User is offlineProfile CardPM
+Quote Post

nick1200

RE: How Can I Know When Download Finished?

29 Jun, 2009 - 01:37 PM
Post #4

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions
QUOTE(livium @ 29 Jun, 2009 - 01:22 PM) *

QUOTE(nick1200 @ 29 Jun, 2009 - 01:18 PM) *

easy make it so when the link or file has you call it is clicked it adds 1 to the database

a table in the database

so you would need a insert fuctions smile.gif


i don't think you understood my question.

i want the file to be donwloaded completely, and then to insert an incremented value in db.



i dont think you can do that tongue.gif

thats why know 1 else is commenting

icon_up.gif


you would have to be real good at coding to know if its downloaded 100% onto some 1 else's computer
User is offlineProfile CardPM
+Quote Post

livium

RE: How Can I Know When Download Finished?

29 Jun, 2009 - 02:02 PM
Post #5

D.I.C Regular
***

Joined: 21 Dec, 2008
Posts: 294


My Contributions
hmmm... i think you're right.
User is offlineProfile CardPM
+Quote Post

AdaHacker

RE: How Can I Know When Download Finished?

29 Jun, 2009 - 02:42 PM
Post #6

D.I.C Regular
***

Joined: 17 Jun, 2008
Posts: 378



Thanked: 83 times
My Contributions
Well, you could download the file through a PHP script and do your database increment after the download completes. For example, something like this:
php

<?php
$path = "/path/to/myfile.rar";
# Add the appropriate content type header so the
# client knows what to do with the data.
header("Content-Type: application/x-rar-compressed");
# Read the file and dump it to the client
readfile($path);
# Post download code for database update etc. goes here

You would then link to this script instead of your RAR file. If the download gets canceled, the script should terminate and the post processing code will never run.

FYI, I have never tried this method in production, so I make no promises about its reliability.
User is offlineProfile CardPM
+Quote Post

livium

RE: How Can I Know When Download Finished?

30 Jun, 2009 - 02:33 AM
Post #7

D.I.C Regular
***

Joined: 21 Dec, 2008
Posts: 294


My Contributions
thanks, i will consider it.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 04:28AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month