How to set a value for file upload button

倾然丶 夕夏残阳落幕 提交于 2021-02-04 08:29:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!