Hello there , currently am working on download site that contain items , I need to place download hits for every file in site, I used the old way that open popup php page and increase the counter then store the result in database, its not cool to do this, so I want to make this works with ajax , the user just click download and start downloading without any popups, what should I do ?
Example with code will be helpful, Thanks.
OsaMasw
13
Loving Helper
Recommended Answers
Jump to PostFor download files not necessarily to use AJAX.
You can this does without use AJAX.<a href="download.php?file_id=123456" target="_blank">Download File</a>
download.php
//execute any actions //get $file_name by file_id if(file_exists($file_name)) { $ext = pathinfo($file_name, PATHINFO_EXTENSION); switch($ext) { case "pdf": $ctype="application/pdf"; break; case "zip": $ctype="application/zip"; break; …
Jump to PostWhen you click the button you could create a iFrame with Javascript and display:none; in css, that would download right on the page.
All 6 Replies
radow
7
Junior Poster in Training
OsaMasw
commented:
I was need for Ajax just for not to relode page, but this code may come in handy someday , thanks
+0
NardCake
30
Posting Pro in Training
OsaMasw
commented:
Thats what i was looking for
+0
radow
7
Junior Poster in Training
radow
7
Junior Poster in Training
annaonweb
0
Newbie Poster
OsaMasw
13
Loving Helper
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.