On Monday, September 20th, 2021 at 11:19 PM, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote: > On 20 September 2021 22:49:25 BST, ourdiaspora ourdiaspora@xxxxxxxxxxxxxx wrote: > $targetfilepath = $uploaddir . $uploadfile; if(isset($_POST["submit"])){ $filename=$_FILES["userfile"]["tmp_name"]; if($_FILES["file"]["size"] > 0){ $file = fopen($filename, "r"); while (($getdata = fgetcsv($file, 10000, ",")) !== FALSE){ $dbdataentry = "INSERT INTO somedata(name, id, emailaddress, groupname) VALUES ('".$getdata[0]."','".$getdata[1]."','".$getdata[2]."','".$getdata[3]."')"; $result = pg_query($dbconnect, $dbdataentry); } } fclose($file); } > > > So what exactly is your code doing? Check each part: > > > Did you attempt to use any kind of simple print statement debugging to see if any of your assumptions are correct? Changed the file to: " ... $targetfilepath = $uploaddir . $uploadfile; $filename=$_FILES["userfile"]["tmp_name"]; if(isset($_POST["submit"])){ $filename=$_FILES["userfile"]["tmp_name"]; if($_FILES["file"]["size"] > 0){ $file = fopen($filename, "r"); while (($getdata = fgetcsv($file, 10000, ",")) !== FALSE){ $dbdataentry = "INSERT INTO somedata(name, id, emailaddress, groupname) VALUES ('".$getdata[0]."','".$getdata[1]."','".$getdata[2]."','".$getdata[3]."')"; $result = pg_query($dbconnect, $dbdataentry); } } fclose($file); } print "filename is $targetfilepath"; ... " The file path was correctly printed in the web browser. Then substituted the last line above to: " ... print "filename is $filename"; ... " The filename was _not_ printed in the web browser. Then substituted for: " ... print "filename is $_FILES"; ... " Result printed in web browser: " ... Notice: Array to string conversion in ...filename is Array ... " Then substituted for: " ... print "filename is $file"; ... " Result printed in web browser: " ... Notice: Undefined variable: file in ... " Then substituted for: " ... print "filename is $getdata"; ... " Result printed in web browser: " ... Notice: Undefined variable: getdata in ... " So it would seem that these variables are not being accepted?