help in header(); function
Moderator: General Moderators
help in header(); function
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
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
- BlaineSch
- Forum Commoner
- Posts: 28
- Joined: Sun Jun 07, 2009 4:28 pm
- Location: Trapped in my own little world.
Re: help in header(); function
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?
If I got this wrong can you show us your source?
Re: help in header(); function
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?
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?
- iankent
- Forum Contributor
- Posts: 333
- Joined: Mon Nov 16, 2009 4:23 pm
- Location: Wales, United Kingdom
Re: help in header(); function
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
to enable resuming downloads:
Code: Select all
header('Accept-Ranges: bytes');Code: Select all
header('Accept-Ranges: none');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
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
or put the path in a Session like this
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
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];Code: Select all
$_SESSION['filepath'] = $getf3[path];but if i directly put the pat in a avriable like this
Code: Select all
$filepath = 'file.zip';i don't know why this is happening and i am looking for ur help please
- iankent
- Forum Contributor
- Posts: 333
- Joined: Mon Nov 16, 2009 4:23 pm
- Location: Wales, United Kingdom
Re: help in header(); function
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.trazan wrote:the download will resume
i don't know why this is happening and i am looking for ur help please
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
there is no whitespace in the filepath in the database
and the download is done correctly but why there are no resume

and the download is done correctly but why there are no resume
Re: help in header(); function
i wating ur help
- iankent
- Forum Contributor
- Posts: 333
- Joined: Mon Nov 16, 2009 4:23 pm
- Location: Wales, United Kingdom
Re: help in header(); function
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
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