|
Posted by jussist@gmail.com on 07/07/06 08:53
Robert S wrote:
> > Why are you even passing the filename in a button's name?
> >
> > Why not:
> >
> > <form action=test.php method=post>
> > <div>
> > <input type=hidden name=myfile value="filename.txt">
> > <input type=submit>
> > </div>
> > </form>
>
> The page is a fax client that allows large numbers of files to be faxed
> off to multiple recipients. I have a whole lot of buttons and text
> inputs that refer to different files. The receiving page loops through
> $POST and identifies the file that the button refers to. All text
> inputs and checkboxes etc need to be sent to the receiving page, so I
> can't use multiple <form> elements. The example I gave was just an
> illustrative example - its not from my code. As far as I can see this
> seems to be the only way of doing it. The files are .PDF files created
> by cups-pdf - so they are FULL of underscores. If I use an <a href>
> tag, the POST variables don't get sent to the receiving page.
>
> bin2hex looks like the way to go.
In my mind if you cannot avoid having those periods in the form-fields,
you have a design problem in your code. For example:
<input type="hidden" name="filename1" value="filename1.txt">
<input type="submit" name="SubmitStuff1">
<input type="hidden" name="filename2" value="filename2.txt">
<input type="submit" name="SubmitStuff2">
With this kind of stuff on the target page you get the filename by:
if( isset($_POST["SubmitStuff1"])) {
$MyFilename = $_POST["filename1"];
}
or
for($i=0;$i<100;$i++) {
if(isset($_POST["SubmitStuff".$i)) {
$MyFilename = $_POST["filename".$i];
}
}
and so forth. You never really need a period in the field name, unless
the form is produced by some other software, generator, or some
framework, but these are other issues then.
Navigation:
[Reply to this message]
|