Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

salamaslam.official's avatar

Get previous value of file in form after validation failed

I am trying to get old values with the old method, it's working for me but it's not working for input[type=file] I am using the following code to get the old file value

0 likes
4 replies
Snapey's avatar
Snapey
Best Answer
Level 122

you cannot provide a value to the file input. You user will have to select the file again

1 like
salamaslam.official's avatar

@Snapey is there any other way to be get selected the file

I am developing a non-js application. And making Multistep form, so that is why I have to do this

Snapey's avatar

@salamaslam.official if you could specify the file then you could hide the file input element and steal any file you liked from the user's computer. You need to save the file on that step. You can pass forward a reference to where you have put the file, and if the user presses back, remind them of the filename they uploaded, with an option to upload something different

1 like

Please or to participate in this conversation.