-2

I have a basic HTML form where the user can select files.

<input multiple type="file" name="file"/> 
<input  type="submit" name="submit" value="Submit" />

The user will be redirected to this form after clicking on a well specific button (present on the home page). Let's say I have 3 differents buttons.

If the user clicked on button1 I would like to redirect him to mysite/myform.php?var=button1. I would also like to pre-fill the input file with a specific file located server-side : button1.txt

So I know which file is he wanting because of the URL and pick it with PHP code (server-side) and send it to the html page (with javascript).

Is it possible to fill in the form using this way?

Atnaize
  • 1,766
  • 5
  • 25
  • 54
  • You don't need a form to let a user download a server side file. Forms are meant to input/upload data not for displaying/downloading. All you need is the link to that file and a proper content disposition from php. – Rahul Kate Feb 04 '16 at 13:47
  • Check this link:- http://stackoverflow.com/questions/20769606/how-to-redirect-a-page-using-onclick-event-in-php – Ravi Hirani Feb 04 '16 at 13:47

1 Answers1

0

Since it is a yes/no question the answer is yes. You need to create a proper form for your need and set the values of those inputs with selected file. You migh want to put them(the variables in that file) in a array or json format(or some other like xml... your choice) so it will be easier for you to traverse the file user selected. And check this quesiton also.It can help you to create what you want: Parsing JSON file with PHP

Community
  • 1
  • 1