Jump to content

Recommended Posts

Hi there,

 

I wanted to create files from my phpscript. So I used the most obvious function, fopen(). It didn't work on my server and contacted the administrator, who said fopen() was disabled for security reasons, and that I should use cURL. So I did what everyone would do; I googled it. Found the php.net curl manual, but can't really comprehend what it sais. So I have a few questions:

 

1) Can you create .php files with cURL?

2) How?

3) How do I then write php-content in the file?

 

Please try to explain rather detailed and simplified, I've never been good at quickly understanding all these things.

 

Thanks a lot!

Link to comment
https://forums.phpfreaks.com/topic/211104-curl/
Share on other sites

No, cURL can't "create" files, it commonly used to read contents from other sites and post requests

I would suggest using file_put_contents however it depends what your attempting to write,

 

here is an example from PHP.net

<?php
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith\n";
// Write the contents back to the file
file_put_contents($file, $current);
?>

Link to comment
https://forums.phpfreaks.com/topic/211104-curl/#findComment-1100928
Share on other sites

Well what I want to do is actually be able to generate a whole webpage by the click of a button...

 

It would get a random name, eg AsUjeZee.php, and it also creates a database with the same random name(this part I have already). The random php file should then be able to connect to the same-named database and show all the queries.

 

On the other hand, I could make it with one single phpfile and a $_GET containing the random name, but I don't really like to work with $_GET[] since it seems rather unsafe...

Link to comment
https://forums.phpfreaks.com/topic/211104-curl/#findComment-1100938
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.