You are here: Re: CSV file into an array « PHP Programming Language « IT news, forums, messages
Re: CSV file into an array

Posted by Erwin Moller on 03/09/06 11:07

Stephen Preston wrote:

> Hi
>
> Can anyone explain in layman's terms the sequence of events required to
> upload a csv.txt and put the contents into an array.

Hi,

>
> Lets assume I have a form to select the csv.txt file, which then uploads,
> then what happens to it? where does it go? how do I get it out of the
> ether?

It goes a a temp directory under a temp name.
You can easily retrieve it and store it in a place you want it to be.
This is done by the code in the receiving script (= the script mentioned in
the action-tag of the form that contains the file-selector for the
fileupload.)

Read more here:
http://nl2.php.net/manual/en/features.file-upload.php


> How, where do I access it. Looking at the PHP manual, I deduce that I
> need to some how use the fopen and fgetcsv but unfortunately it reads like
> gobbledygook to me at the moment.

First get the upload up and running, then start with the handling of the
file.
fgetcvs() is a nice helperfunction, but you can do it by hand too.
Really, just try it.
No use in us telling you what to do to the letter if you don't understand it
yourself.

If you want to test your result somehow (the array), a handy function is
print_r(). It prints the, possibly complex, structure of the array.
Use pre, like this:
<pre>
<? print_r($yourResultArray); ?>
</pre>

>
> I can do, see and understand that if it was a picture, it goes into a
> directory on the server and resides there, but I don't want the csv.txt
> file to be saved.
>

Then delete it afterwards.
unlink()

Regards,
Erwin Moller

 

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

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