I have been trying to upload a CSV and manipulate the data but I dont think its being uploaded properly. My code is:
HTML
<form action="import_script.php" method="post" enctype="multipart/form-data">
Please select a file in the form of a CSV
<input type="file" name="file" id="fileToUpload">
<input type="submit" value="Upload CSV" name="submit">
</form>
PHP
$csv_import = fopen($_FILES['file']['tmp_name'], 'r+');
//Echo file details
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
$row = fgetcsv($csv_import, 8192);
print_r($row);
The echoed output is:
Upload: Data_July_6_2017.csv
Type:
Size: 0 Kb
Temp file:
Im trying to get it to upload previously generated csv file and read print the results of a fgetcsv() on the first row but I am getting no data from the file and the file info appears all wrong.