I am uploading a csv file with this code:
$_ferror = $_FILES['file']['error'];
$_fsize = $_FILES['file']['size'];
$move = move_uploaded_file($_FILES['file']['tmp_name'], $_fpath."/" . $url);
where $_fpath contains the path to the directory where I want the files stored and the $url contains the file,name: "$url = $_FILES['file']['name'];"
my question is, how can I open the file, before I move it... I want to read from it and take the data in it, and then create 3 files from the one...
Based upon data I find in it.
Say I want these three files:
currentdate-type1.csv currentdate-type2.csv currentdate-type3.csv
Say the csv has these fields:
name,phone,type,email,address1,address2,city,state,zip,country
then I open it, find the "type" and if the type is, say, good, then put that whole line in a file I name currentdate-type1.csv, then if the type is great, put that in currentdate-type2.csv and if the type is awesome I put those lines in currentdate-type3.csv...
I guess, I could have it where the original file is the type1, then I just pull out those for type2 and type3....
Those are just examples, not really what I am wanting to do. I just cannot figure out how to start.
I want to start by reading the file... getting the first line, into an array of all the field names, so I can check which one is the field I want to get the data from in the data-rows....
Can you tell me how to open that file to read from it, getting the first line... for the fieldnames?
I would really appreciate tips, or where to find that on php training pages.
Thank you so very much in advance for any tips and/or pointing me to where I can learn that specifically how to...