Link to home
Start Free TrialLog in
Avatar of Computer_Dilo
Computer_Dilo

asked on

Displaying the contents of FileField in a form via PHP when redisplayed due to validation failure

In PHP when you are processing a form and don't get the right answers or have missing fields and redisplay the form using value=$_POST['fieldname'] to display the information which was entered before, how do you display the filename which was entered into a FileField?
Avatar of hernst42
hernst42
Flag of Germany image

Thats not possible. The value of <input type="file"> is neither writeable via HTML nor via JS, only via user interactions. THis is due security reasons as else forms could steal files from the user without permisions of the user.
Avatar of Roonaan
A solution might be to implement additional Javascript form validation, such that the missing fields are detected clientside.
Note that this should not replace your serverside validation as not everyone might have javascript enabled.

-r-
Avatar of Computer_Dilo
Computer_Dilo

ASKER

That's what I thought hernst42 - except I didn't know why exactly (thanks). So would there be another way with a normal text field used to load a file using PHP code??
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial