note 57454 added to function.tmpfile
| From: | chris | Date: | Tue, 04 Oct 2005 19:14:54 +0000 |
| Subject: | note 57454 added to function.tmpfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96385@lists.php.net to get a copy of this message | ||
I found this function useful when uploading a file through FTP. One of the files I was uploading was
input from a textarea on the previous page, so really there was no "file" to upload, this
solved the problem nicely:
<?php
# Upload setup.inc
$fSetup = tmpfile();
fwrite($fSetup,$setup);
fseek($fSetup,0);
if (!ftp_fput($ftp,"inc/setup.inc",$fSetup,FTP_ASCII)) {
echo "<br /><i>Setup file NOT inserted</i><br /><br />";
}
fclose($fSetup);
?>
The $setup variable is the contents of the textarea.
And I'm not sure if you need the fseek($temp,0); in there either, just leave it unless you know
it doesn't effect it.
----
Manual Page -- http://www.php.net/manual/en/function.tmpfile.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57454
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57454&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57454&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57454&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57454&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57454&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57454&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57454&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57454&report=yes
Search -- http://master.php.net/manage/user-notes.php