Question

When i use an html form to post a file, how do i address that file's contents in php?

will this work?

$data = $_POST['file'];
$pre = explode(";;;", $data);

the file is a text file btw

UPDATE
the csv is field enclosed with ::: and lines terminated by ;;;. How can i load this into a variable without breaking the php script, which is what is happening now

Was it helpful?

Solution

umm you can do

$data = file_get_contents($_FILES['file']['tmp_name']);
$pre = explode(";;;", $data);

something like that should work

OTHER TIPS

No, it will not work. You'll need to save the file locally, first, and open the file with something like file_get_contents(). Please read the PHP Tutorial on File Uploads

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top