Page 1 of 1
help in header(); function
Posted: Fri Nov 20, 2009 10:43 pm
by trazan
hello everyone
i use header() function to make a download page to hidden the link from the visitor
when i use it only in the page it workes perefect and the download support resume
but when i use it in a page but before it some MySql queries & starting a Session it work but the downlaod dosen't support resume
i just need to know how i can make the download in the second page support resume and how i can control in ( support resume ) cuz maybe i want to stop it for some members
thanks alot
Re: help in header(); function
Posted: Fri Nov 20, 2009 10:59 pm
by BlaineSch
You want to stop it for some members? I'm not really sure what your saying here. If your using a database you can simple add another column 'enabled' to see if they are allowed to download etc. Once the download has started I do not believe it's possible to stop the download.
If I got this wrong can you show us your source?
Re: help in header(); function
Posted: Sat Nov 21, 2009 9:05 am
by trazan
sorry cuzmy english not perfect
i alerady mad a colum ( resume) if it's value=1 the download will support resume , if it's value=2 the download will not support resume
i just want to know how can i make the download support resume cuz when i put the functon [ header() ] in the midell of the page the download wasn't support resume i think the Session function is the reason, am i right?
Re: help in header(); function
Posted: Sat Nov 21, 2009 9:10 am
by iankent
Send the header 'Accept-Ranges:', e.g.
to enable resuming downloads:
and to disable resuming downloads:
unfortunately, thats only an instruction to the downloader, and may not guarantee that the download wont attempt to resume anyway.
The next thing you need to do is take notice of the $_SERVER['HTTP_RANGE'] variable. Easiest to have a look at an example:
http://stackoverflow.com/questions/1573 ... d-the-file
hth
Re: help in header(); function
Posted: Sat Nov 21, 2009 9:18 pm
by trazan
thanks (iankent) i am already use this code but i found the problame at least
when i receive the file path from database like the
Code: Select all
$id=$_POST['id'];
$getf="SELECT * from filez where id='$id'";
$getf2=mysql_query($getf) or die("This Is Worng Fils Or It Has Been Deleted");
$getf3=mysql_fetch_array($getf2);
$filepath=$getf3[path];
or put the path in a Session like this
Code: Select all
$_SESSION['filepath'] = $getf3[path];
the download will not resume
but if i directly put the pat in a avriable like this
the download will resume
i don't know why this is happening and i am looking for ur help please
Re: help in header(); function
Posted: Sun Nov 22, 2009 5:42 am
by iankent
trazan wrote:the download will resume
i don't know why this is happening and i am looking for ur help please
If the only difference is that you're outputting the filename from a database instead of it being hardcoded that shouldn't make any difference to how the script works.
Have you checked you're not outputting any whitespace that could be affecting things? Maybe easier to leave the closing ?> bracket off the end and make sure the opening <? is right at the start so no spaces can be accidentally output.
If that doesn't help, and apart from retrieving the filename the script is identical every time, try var_dump'ing the filename in the different circumstances to see if there's a problem with the file names
very odd!
Re: help in header(); function
Posted: Sun Nov 22, 2009 9:59 am
by trazan
Re: help in header(); function
Posted: Sun Nov 22, 2009 6:31 pm
by trazan
i wating ur help
Re: help in header(); function
Posted: Tue Nov 24, 2009 9:36 am
by iankent
Did you look at the link I sent you? It explains how to enable resumable downloads using PHP.
Even if Apache is configured to give you resumable downloads, if it believes for any reason that the file won't be the same next time its accessed, it may not give the client the option of resuming to prevent data corruption. In this case, you'll need the manually write the resuming code yourself