You are here: Re: Best way to get the contents of a local file in a server variable « PHP Programming Language « IT news, forums, messages
Re: Best way to get the contents of a local file in a server variable

Posted by Rik Wasmus on 10/29/07 19:30

On Mon, 29 Oct 2007 20:07:29 +0100, Fons <fons@fons.invalid> wrote:

> My script acts on a file (approx. 100k) offered by the user. Actually,=
it
> acts on a variable that should have the contents of that file in it. I=

> could try to let users upload that file and then read that file into a=

> variable, but before I figure out how to do that: is this unnecessary
> overhead? Is it possible to do it without creating a file on the serve=
r
> filesystem and do it completely within the PHP framework? What method
> would you recommend?

Just let it do a normal fileupload to a/the tmp directory and read it in=
to =

a variable. Anything else will be a waste of time. The code is pretty =

simple:

if(isset($_FILES['your_html_fileinput_name'])){
if($_FILES['your_html_fileinput_name']['error']!=3DUPLOAD_ERR_OK){
echo 'upload error #'.$_FILES['your_html_fileinput_name']['error'];
} else {
$filecontents =3D =

file_get_contents($_FILES['your_html_fileinput_name']['tmp_name']);
}
} else {
echo 'no upload took place';
}
-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация