简体   繁体   中英

How to upload image automatically if user wants to edit info PHP MySQL?

I have created a registration form which takes inputs username, email, password, and image. If user wants to edit his profile, I add all values in inputs and user can submit form again. But when he click on update button the image should be uploaded automatically and not empty. On my end it is empty. You can see in the image that user want to update Info but can't see the uploaded image. Other info was retrieved.

my front end screenshot:

我的前端截图

I tried to show the image using src attribute but this isn't going to work. Please let me know how I can achieve this.

A file input can only select from the local filesystem, so you can't pre-populate it with something from the server.

Use an <img tag to display existing images from the server.

For example, in your HTML form:

File:-
    <input type="file" name="image"><br><br>
    <input type="hidden" name="old_image" value="<?php echo $row['images'] ?>">
    <img src="<?php echo "files/images/".$row['images']; ?>">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM