So, I have a user registration page and want an image to be displayed by default in the page and that image should be uploaded to the database if the user is not changing the image. What I have done is in the preview div, just wrote the image tag to display the picture and set the value of the input type to an image which is in a specific folder. So here is how the code is looking like
<div id="list">
<img src="backimages/dp.png">
</div>
<input type="file" name="file" id="files" value="backimages/dp.png">
when I hit the submit button dp.png is not being store in the database, but when I chose a file by clicking on the choose file button that is successfully being uploaded.
答案 0 :(得分:3)
你不应该这样做。 相反,在您接受图像的服务器中,应该检查它是否为空,如果是这种情况,请使用默认图像。