|
użytkowników online: 65
|
OPINIE UŻYTKOWNIKÓW
|
Nie jestem webmasterem, ale i na mnie zrobiła wrażenie szybkość reakcji Darka na mój problem. Jego kompetencja i przede wszystkim zupełnie niemodna w dzisiejszych skomercjalizowanych czasach - zwykła ludzka życzliwość dla innego człowieka. Tacy ludzie to dziś gatunek niemal wymarły...
Leszek
Wojskowy Instytut Medyczny
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
tmpfile (PHP 3 >= 3.0.13, PHP 4, PHP 5) tmpfile -- Tworzy plik tymczasowy Opisresource tmpfile ( void )
Tworzy plik tymczasowy o unikalnej nazwie i otwiera go
w trybie do odczytu i zapisu (w+), zwraca uchwyt pliku, podobnie jak
fopen().
Plik jest automatycznie kasowany przy zamykaniu (po użyciu
fclose()), lub gdy skrypt się zakończy.
Jeśli chcesz uzyskać więcej szczegółów, zajrzyj do dokumentacji
twojego systemu dotyczącej funkcji tmpfile(3),
albo do pliku nagłówkowego stdio.h.
Przykład 1. tmpfile() przykład |
<?php
$temp = tmpfile();
fwrite($temp, "zapisywanie do pliku tymczasowego");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp); ?>
|
Powyższy przykład wyświetli: zapisywanie do pliku tymczasowego |
|
Patrz także: tempnam().
User Contributed Noteschris [at] pureformsolutions [dot] com
04-Oct-2005 09:14
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
$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.
onlywhenitscold at doglover dot com
06-Feb-2005 09:33
tmpfile() does not return the name of the file it created.
To get access to the file, use something like this:
$tempfn = tempnam("","");
$temp = fopen($tempfn, "w");
fwrite($temp, $data);
fclose($temp);
//your functions here, ie:
$size=getimagesize($tempfn);
unlink($tempfn);
|