Direct Download Not Working
Direct Download Not Working
Thanks for this beautiful software. It solved my count problem except I'm now facing a new one. When I try to force direct download on my file using html code, the browser tries to download "Click.php." This happens for opera mini and some browsers won't just download. Please what can I do? Thanks for your help.
Re: Direct Download Not Working
I would have to see your setup in action to be sure, but you will most likely need to modify the code (headers PHP sends) to set the correct file name etc.
Or use the alternative HTML redirect and modify the code there (the bottom few lines) to force the download?
https://www.phpjunkyard.com/extras/ccou ... _click.zip
Or use the alternative HTML redirect and modify the code there (the bottom few lines) to force the download?
https://www.phpjunkyard.com/extras/ccou ... _click.zip
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Direct Download Not Working
Hi,
Thank you for your kind help. I was trying to respond earlier but I couldn't post because I was receiving some error messages. In response to your reply, here's the code I'm using:
Also there's an "onclick" ref code that leads to the thank you page placed after the "file name" code.
But when someone hits the "Download Now" button, the browser tries to download click.php. Kindly help.
Thank you for your kind help. I was trying to respond earlier but I couldn't post because I was receiving some error messages. In response to your reply, here's the code I'm using:
Code: Select all
<head><script src="mydomain/assets/counter/display.php"></script></head>
<body><div class="buttonHolder">
<form>
<a href="mydomain/assets/counter/click.php?id=1" download="file name" target="_blank"><input class="button" type="button" value="DOWNLOAD NOW" /></a>
</form>
<script>ccount_display('1')</script>
</div>
</body>
But when someone hits the "Download Now" button, the browser tries to download click.php. Kindly help.
Re: Direct Download Not Working
That is probably mod_security detecting the post as a possible hacking attempt and blocking it.prodbyola wrote: Fri Mar 01, 2019 1:37 amI was trying to respond earlier but I couldn't post because I was receiving some error messages.
I don't see anything wrong with the code you posted. You could try it without <form> tags and see if that helps.
If not, please share your exact page code (you can do it in a private message for privacy concerns).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Direct Download Not Working
Hi @Klemen,
Thanks for the assistance so far. I'm using wordpress and I'm just trying to insert the html code into a post. So I don't really know how to get the code for the whole page to you. But when I replaced the form tags with "div", I got the same result as above. Is there an alternate that may work? Thank you?
Thanks for the assistance so far. I'm using wordpress and I'm just trying to insert the html code into a post. So I don't really know how to get the code for the whole page to you. But when I replaced the form tags with "div", I got the same result as above. Is there an alternate that may work? Thank you?
Re: Direct Download Not Working
Can you show the page (URL) where this is happening?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Direct Download Not Working
Thanks @Klemen
The here's a sample page I'm working on https://lix.tdmstudios.com.ng/psalm27-imhudia/. The "Download Now" button tries to download "Click.php" in Opera Mini and doesn't work properly in other browsers.
The here's a sample page I'm working on https://lix.tdmstudios.com.ng/psalm27-imhudia/. The "Download Now" button tries to download "Click.php" in Opera Mini and doesn't work properly in other browsers.
Re: Direct Download Not Working
Two problems I see:
1. Your link ID 1 is not a valid MP3 file, but redirects to the page itself:
The ID 1 link in Ccount admin panel should be set to the MP3 file:
2. Remove this code from the link:
1. Your link ID 1 is not a valid MP3 file, but redirects to the page itself:
Code: Select all
https://lix.tdmstudios.com.ng/assets/counter/click.php?id=1
Code: Select all
https://lix.tdmstudios.com.ng/wp-content/uploads/2019/01/imhudia_psalm37.mp3
Code: Select all
onclick="location.href='https://lix.tdmstudios.com.ng/thank-you/';"
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Direct Download Not Working
Oh! That was a mistake which I just corrected now. Initially I actually set the file link https://lix.tdmstudios.com.ng/wp-conten ... salm37.mp3 in CCount admin and I was getting the same result. Now I've followed both instructions you just gave me but unfortunately... I'm still getting the same result 

Re: Direct Download Not Working
How about if you add something like this in click.php just below line starting with setcookie?
I didn't test it so if you get an error (or 0 file size), try adding one more "../" to the $file['path'] line.
Code: Select all
$url = parse_url(str_replace('&', '&', $ccount_database[$id]['L']));
$path = isset($url['path']) ? pathinfo($url['path']) : array();
if (isset($path['extension']) && strtolower($path['extension']) == 'mp3')
{
$file['path'] = '../..' . $url['path'];
$file['name'] = $path['basename'];
// Send the file as an attachment to prevent malicious code from executing
header("Pragma: "); # To fix a bug in IE when running https
header("Cache-Control: "); # To fix a bug in IE when running https
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $file['name']);
readfile($file['path']);
die();
}
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Direct Download Not Working
Hi Klemen,
Thanks for your help so far. After trying your instructions above, the browser now tries to get a "click.htm" file.
Thanks for your help so far. After trying your instructions above, the browser now tries to get a "click.htm" file.

Re: Direct Download Not Working
Works fine for me in Firefox and Chrome.
Doesn't work in IE (nothing happens when I click the link, try removing <form> tags around it).
Don't have Opera to test. Try clearing your cache.
Doesn't work in IE (nothing happens when I click the link, try removing <form> tags around it).
Don't have Opera to test. Try clearing your cache.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Direct Download Not Working
Thank you Klemen,
It's already working in Chrome. It's not working on Opera Mini. I tried with a smartphone and tablet. On the smartphone, it tries to download "click-1.php" and the "-1" increases the more I try to download. On the tablet, it tries to download "click.htm." I don't care much about IE as most of my web visitors are likely to be mobile users using Chrome or Opera. So I really wish it could work on opera.
It's already working in Chrome. It's not working on Opera Mini. I tried with a smartphone and tablet. On the smartphone, it tries to download "click-1.php" and the "-1" increases the more I try to download. On the tablet, it tries to download "click.htm." I don't care much about IE as most of my web visitors are likely to be mobile users using Chrome or Opera. So I really wish it could work on opera.
Re: Direct Download Not Working
I am out of ideas, unfortunately. I recommend hiring a PHP developer to login to your server, have a look and try to fix this for you.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Direct Download Not Working
Thank you sooooo much. You've been a great help.