0

Is there a way to using a input file with two different form?

I need only one input file and have to post this file to .php page depending of user selection.

Thanks.

<label for="file">Photo:</label>
<input type="file" name="file" id="file">
<form action="c.php" method="post" enctype="multipart/form-data" >
    <input type="submit" name="submit" value="C">
</form>
<form action="d.php" method="post" enctype="multipart/form-data">
    <input type="submit" name="submit" value="D">
</form>

1 Answer 1

1

You could redirect to page cd.php which includes c.php or d.php depending on the value C or D

Sign up to request clarification or add additional context in comments.

2 Comments

you mean i need to create a cd.php file which only have <?php if(..)include 'c.php'; else include 'd.php';?> ? But i have to use two button
Not necessarily. The "value=D" can selected in another input. For instance have two radiobuttons in your form where the user selects the value and then only one button. Also, depending on the amount of code in your c.php and d.php and the rest of your application, it may be possible to join them in one file and have an if/else clause for the different actions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.