问题
I have an application where we can select image and store it and when user needs to change a properties of image like height,width,image he will go to edit page and he will edit it.. But when the user does not change image if he changes only height and width then the image will no display because the image value will not fetch/set for file... So how can we dynamically set path for a file upload button...
回答1:
If you're talking about the HTML file input then you can't manipulate it's contents programmatically. This is a safety feature in modern browsers. For all intents and purposes you can consider it read-only.
Specs on the HTML file input
回答2:
Answer is simple; you cannot.
Just check whether the image is set. If so, upload the new image. If not, don't replace the image with the image you already have. This is a safety measure, you don't want to be able to upload a file of the websites choise.
来源:https://stackoverflow.com/questions/11756946/how-to-set-a-value-for-file-upload-button