Skip to content
Advertisement

How to keep the previous uploaded image (in db) after submitting a form without selecting a new image to be uploaded

I have a simple form for creating an article: Title,image,category,body , etc.. My problem is with the image input.

Selecting a new one and submitting everything works fine:

  • the image is being uploaded to the server
  • the title of the image is being saved to db
  • and i can print it in the article.

By editing the whole form, filling all fields but leaving the image field as it is, and finally submitting, the image field value in db is changing to nothing.

How can i configure the php file, so every time the user submits the form without selecting an image (if there was an image pre uploaded in that article ) keep as submitted the previous image (from db) instead of nothing.?


If these informations can be of any help:

I can print the image like this : <?php echo '<img src="'.$results['article']->img.'" width="100px">'; ?>

Simple input field for image:

JavaScript

Advertisement

Answer

What about something like this?

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement