Page 1 of 2
Hide Download file URL
Posted: Fri Nov 18, 2011 9:05 am
by Xeolex
i am beginner in php and try to make a website in php..
i want to hide the url of the download file, can any one help me do this??
please help me...
thanks
Re: Hide Download file URL
Posted: Sat Nov 19, 2011 4:00 am
by social_experiment
Re: Hide Download file URL
Posted: Mon Nov 21, 2011 9:51 pm
by Xeolex
i have tryed that one, but its not working...
Re: Hide Download file URL
Posted: Mon Nov 21, 2011 10:55 pm
by twinedev
That is pretty much it. so what isn't working? It gives you errors? It is showing file instead of downloading? What browsers are you trying it in?
-Greg
Re: Hide Download file URL
Posted: Mon Nov 21, 2011 11:27 pm
by Xeolex
i am running this on my localhost using wamp server
and i am using firefox as a browser
Code: Select all
<?php
$path = 'C:/wamp/www/test.avi'; // the file made available for download via this PHP file
$mm_type="application/octet-stream"; // modify accordingly to the file type of $path, but in most cases no need to do so
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($path)) );
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header("Content-Transfer-Encoding: binary\n");
readfile($path); // outputs the content of the file
exit();
?>
its downloading the file but its only able to download 1.3kb from the file..
Re: Hide Download file URL
Posted: Mon Nov 21, 2011 11:46 pm
by twinedev
Open the file in something like notepad++, see if it looks like a source code from a webpage that is displaying an error. If not, and the begining of that file looks the same as the actual file you are trying to get, check what value is being given for Content-Length.
-Greg
Re: Hide Download file URL
Posted: Tue Nov 22, 2011 5:40 am
by Xeolex
twinedev wrote:Open the file in something like notepad++, see if it looks like a source code from a webpage that is displaying an error. If not, and the begining of that file looks the same as the actual file you are trying to get, check what value is being given for Content-Length.
-Greg
????
i dont understand you???
i have checked the content-length and it is same as real file size..
Re: Hide Download file URL
Posted: Tue Nov 22, 2011 5:45 am
by twinedev
Does the 1.3kb of data you get from the download match the first 1.3kb of the file you are trying to download? if not, what is it?
Do not assume what you received from the server was the type of file you think you should be getting. Perhaps there is an error generating from the server, and what you are actually downloading is the error message the server is outputting, just named as what you thought you wanted to get.
-Greg
Re: Hide Download file URL
Posted: Tue Nov 22, 2011 9:52 am
by Xeolex
i am trying to download an avi file(movie)..
when i run the php script it starts downloading the test.avi file,but without any error the download get completed with only 1.3kb file..
thank you
Re: Hide Download file URL
Posted: Tue Nov 22, 2011 10:11 am
by social_experiment
Tried the code in FF and IE9; works fine. Try modifying your path where the file resides.
Re: Hide Download file URL
Posted: Tue Nov 22, 2011 11:35 am
by twinedev
Xeolex wrote:i am trying to download an avi file(movie)..
when i run the php script it starts downloading the test.avi file,but without any error the download get completed with only 1.3kb file..
thank you
If you get an error, since you are "downloading" the output of the script, you will not see it on the screen, it will be in the file, thus, why I said to open the 1.3kb file in a text editor to see what it looks like.
-Greg
Re: Hide Download file URL
Posted: Wed Nov 23, 2011 1:38 am
by Xeolex
here is the file contant
Code: Select all
<br />
<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 945367041 bytes) in C:\wamp\www\test.php on line <i>15</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0008</td><td bgcolor='#eeeeec' align='right'>380496</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\test.php' bgcolor='#eeeeec'>..\test.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0013</td><td bgcolor='#eeeeec' align='right'>381464</td><td bgcolor='#eeeeec'><a href='http://www.php.net/readfile' target='_new'>readfile</a>
( )</td><td title='C:\wamp\www\test.php' bgcolor='#eeeeec'>..\test.php<b>:</b>15</td></tr>
</table></font>
thank you..
Re: Hide Download file URL
Posted: Wed Nov 23, 2011 3:30 am
by social_experiment
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 945367041 bytes) in C:\wamp\www\test.php on line
There's something you can search for. Looks like the file downloaded is the error page.
http://www.tech-recipes.com/rx/777/solv ... ted-tried/
Have a look at this url
Hth
Re: Hide Download file URL
Posted: Wed Nov 23, 2011 10:21 am
by Xeolex
its seem in my php.ini it sets to 128M
anyone knows whats the problem??
and what can i do to overcome this error??
thanks..
Re: Hide Download file URL
Posted: Wed Nov 23, 2011 12:41 pm
by twinedev
And how big is the file you are trying to download?
-Greg