This was working in php 7.4 however upon upgrading to 8.0 there seems to be syntax depricated however I'm not seeing it. Thanks


if(isset($_FILES["myfile"]))
{
	$ret = array();

$error =$_FILES["myfile"]["error"];
   {

	if(!is_array($_FILES["myfile"]['name'])) //single file
	{
   	 	$fileName = $_SESSION[time].$_FILES["myfile"]["name"];
	$Name = $_FILES["myfile"]["name"];

$date = date("Y-m-d");

$query = "INSERT into downloads SET idlesson = '".$_SESSION['less']."', memid = '".$_SESSION['memberid']."', filenameshort = '".$Name."', filename = '".$fileName."'";
mysqli_query($con,$query);

echo $query;

   	 	move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir.$fileName);
   	 	 //echo "<br> Error: ".$_FILES["myfile"]["error"];

       	 	 $ret[$fileName]= $output_dir.$fileName;
	}
	else
	{
	    	$fileCount = count($_FILES["myfile"]['name']);
		  for($i=0; $i < $fileCount; $i++)
		  {
		  	$fileName = $_SESSION[time].$_FILES["myfile"]["name"][$i];
		$Name = $_FILES["myfile"]["name"][$i];

$date = date("Y-m-d");

$query = "INSERT into steam_downloads SET idlesson = '".$_SESSION['less']."', memid = '".$_SESSION['memberid']."', filenameshort = '".$Name."', filename = '".$fileName."'";
mysqli_query($con,$query);

       	 	 $ret[$fileName]= $output_dir.$fileName;
		    move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName );
		  }

	}
}
echo json_encode($ret);

    You didn't post the error, but the problem is likely in the $_SESSION[time] references, about an undefined constant time.

    You must surround associate array index names, which are strings, with either single or double quotes, like all the other usages in the posted code, so that they are strings and won't be interpreted as defined constants.

      Also, note that when you receive such error messages, they include the file name and line number where the error was detected. Often it also quotes the part of the line that it has trouble with. This information can be helpful in tracking down the reason for the message.

      (The $_SESSION[time] mistake would have started emitting deprecation messages back in 7.2.0; ignoring those would have meant your code would break in 8.0.)

        Write a Reply...