Our site creates files on-the-fly that present user-specified data to the world on the web.
There is in each such ‘_present.php’ file a form that needs to post to itself — only problem is, the file is created dynamically based on uploaded user data and the filename is also somewhat arbitrary.
Here’s the process
1) a 'standard' file called _present.php has a common form "TheForm" in it
2) this file, _present.php, is copied to Yf9iZ17a.php (for example) when
the user uploads data -- and from that point, Yf9iZ17a.php presents
that user's just-uploaded data
3) and "TheForm" is inside this Yf9iZ17a.php, which again is just a copy of
_present.php, but modified to handle the user's just-uploaded data
Pretty simple. _present.php has “TheForm” inside it; the user uploads their data; we copy _present.php to a
filename for that user’s data.
The PROBLEM is — we need TheForm to post to its own
filename, which is dynamically created.
In other words, this won’t suffice:
<form name="TheForm" method="post" action="_present.php">
However, this WOULD work:
<form name="TheForm" method="post" action="Yf9iZ17a.php">
But we cannot hard-code the form’s html with “Yf9iZ17a.php” because — that filename is created
dynamically, on-the-fly, at runtime.
This is one failure we have succeeded in executing:
<form name="TheForm" method="post" action="<?php echo __FILE__ ; ?>">
A ‘View Page Source’ sure enough proves that “php echo FILE” correctly echos the
full path (not relative path, the full path) to Yf9iZ17a.php.
Well that won’t work. Giving the browser the fully-qualified pathname to a file —
a file that is on the server — well why would you WANT to do it in the first place unless
you’re grasping at straws. So that was a failure.
Surely this comes up, dynamically created filenames whose internal forms must post to those filenames —
what’s the best way to solve this problem?
You can use this instead, perhaps?