Re: use fopen unknown resource

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: ourdiaspora <ourdiaspora(at)protonmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: use fopen unknown resource
Date: 2021-08-28 22:18:35
Message-ID: CAKFQuwZHigL6TvOOjXmyeXfz9EOdFarh1CHcnekmTwOuERphVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Aug 27, 2021 at 2:59 PM ourdiaspora <ourdiaspora(at)protonmail(dot)com>
wrote:

> Please what is the syntax to assign an unknown file name to the 'fopen'
> function?
>
>
There isn't one as it would make no sense - how is it supposed to open a
file if there is no filename provided to open?

You have to set things up yourself so that the content you want to open
exists in a file at a known location and then pass that location to the
function. In particular, in a web server context, that means taking the
request input from the client that represents a file and saving it
somewhere first - then opening that saved content. If the user is
supplying a suggested file name for the content you can incorporate that.
You can also ignore it and just make something up. It doesn't matter
(other than concerns about overwriting existing files). But whatever name
you choose to give to the newly created file on the server is the one you
pass to fopen. The name/location of the file on the client machine is
irrelevant - the server cannot even see that machine (or, at least should
not care even if it technically can) per the fundamental architectural
principle of "client-server" design.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-08-28 22:26:21 Re: Can we get rid of repeated queries from pg_dump?
Previous Message ourdiaspora 2021-08-28 21:55:19 Re: use fopen unknown resource