Re: postgresql csv import; temporary directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday, September 24th, 2021 at 9:54 PM, ourdiaspora <ourdiaspora@xxxxxxxxxxxxxx> wrote:

> Just realised that the function 'sys_get_temp_dir' returns:
>
> "
>
> /tmp/...[random string]
>
> "
>
> and not the temporary directory specified in the phpinfo() file.
>

Readers,

Pleased to announce _very_ simple successful ability to upload csv file, _without any security validation_. Posted here just in case someone benefits.

"
...
$uploaddir = '/tmp/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
$dbconnect = pg_connect("dbname=... user=...");
$targetfilepath = $uploaddir . $uploadfile;
$filename=$_FILES["userfile"]["tmp_name"];
$file = fopen($filename, "r");
$getdata = fgetcsv($file, 10000, ",");
$dbdataentry = "INSERT INTO tablename(name, id, emailaddress) VALUES ('".$getdata[0]."','".$getdata[1]."','".$getdata[2]."')";
$result = pg_query($dbconnect, $dbdataentry);
pg_freeresult($result);
pg_close($dbconnect);
...
"




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux