Jump to content

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

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.