***Solved*** File download using PHP

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

***Solved*** File download using PHP

Post by alex4orly »

I am trying to call a PHP function from a button click... Not working
Add into the button Inside Tag : onclick="<?php echo download('memberslogin.php'); ?>"

Trying to call the function :

<?php
function download($filename)
{
.....
}
?>
User avatar
Pablo
 
Posts: 21575
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: File download using PHP

Post by Pablo »

You cannot call a PHP function via JavaScript.
JavaScript runs in the browser, PHP on the server.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: File download using PHP

Post by alex4orly »

Is OnClick JavaScript?
User avatar
BaconFries
 
 
Posts: 5327
Joined: Thu Aug 16, 2007 7:32 pm

Re: File download using PHP

Post by BaconFries »

@alex with this being said and you still need to download a file(s) the following URL describes and gives a demo/download of how to achieve this using a protected page. Maybe by downloading the demo zip it will help you to achieve even if it means you have to modify it. Note that Navaldesign is on holiday I believe so any questions you may have about this will/go unanswered till he returns.
https://www.wysiwygwebbuilder.com/forum ... 44&t=20970
User avatar
Pablo
 
Posts: 21575
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: File download using PHP

Post by Pablo »

Yes, onclick is JavaScript.
Note that PHP code is not send to the browser. It is processed on the server.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: File download using PHP

Post by alex4orly »

Thanks Baconfries,

The sample project and code worked for me just fine

Cheers
User avatar
BaconFries
 
 
Posts: 5327
Joined: Thu Aug 16, 2007 7:32 pm

Re: File download using PHP

Post by BaconFries »

,👍
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: ***Solved*** File download using PHP

Post by alex4orly »

I am missing one final step.
I need to download the data file which is in my case members.php with the 'I ' separator to an actual csv file, comma selarated..
Any suggestions?
Cheers
Post Reply