Jump to content

Simple question..


Michdd

Recommended Posts

That's a very vague question.  Are you creating the file?  Is the file being uploaded?  Is the file being passed to the server via a different process?

 

Please be more specific.

Sorry, I mean say I have a variable $url = "http://site.com/picture.png"; How would I save that file? Basically saving a file from an outside source.

Link to comment
https://forums.phpfreaks.com/topic/142913-simple-question/#findComment-749272
Share on other sites

There are a lot of ways, as stated by the previous poster, depending on what you're saving. As for simple plain text the simplest would be..

 

<?php
$content = "test content";
file_put_contents('myfile.txt', $content);

 

For less trivial text examples (eg. to save memory, since file_put_contents requires the full text to be loaded into memory) look into the fopen()/fwrite()/fclose() functions in the manual. ( http://us.php.net/manual/en/function.fopen.php )

Link to comment
https://forums.phpfreaks.com/topic/142913-simple-question/#findComment-749276
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.