views:

103

answers:

1

Hi

I'm trying to develop an online formbuilder. Each user can build their own forms and I want to be able to provide a button that when clicked will download the users html form page along with its css file as a zip file.

I know how to zip the files, but my problem is that the main users html form page doesnt exist as seperate file, its url is in a query string such as:

 http://localhost/form.php?id=9

So was wondering how this could be done

thanks

rifki

A: 

Just use file_get_contents, curl, or fopen to write the content of the url to file on disk... then zip that up. Exmaple:

$formContent = file_get_contents('http://localhost/form.php?id=9');
$formFile = 'path/to/tmp/form.html';
file_put_contents($formFile, $formContent);

//code to zip up css and form.html
prodigitalson
Hey thats great, thanksbut how would I do this for all users without having to repeat the code with different id numbers?thanks
Rifki
You could grab all the ids in an array and loop through it, you could make a function that takes an id or a full url as an argument... or a number of other things.. you didnt really give enough info to answer that effectively.
prodigitalson