refreshing images while editing a record

images php coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Mon May 23, 2011 12:20 am

refreshing images while editing a record

Postby drnick » Mon May 23, 2011 12:31 am

Hi All,

I am new here and I have been getting to grips with PHP by building an application. I would like some advice on refreshing images while a user edits a record.

I have an app which a user is able to store images with details about them. The problem I am encountering is that if a user edits the fields and then clicks a button to upload/change the image I need to refresh the page in order to show the image next to the record. If i do this without submitting the changes, the user will need to enter the details all over again.

I am not after code in general, just an idea of the logic that I can use to sort this problem out. Can I do a submit in conjunction with image upload button so that the posted values can be stored in the page without submitting changes to the database? (the user may want to cancel). I am a bit stuck and would like the process to be as easy as possible.


User avatar
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: refreshing images while editing a record

Postby Nullsig » Mon May 23, 2011 8:34 am

You have 2 choices here.

1. You could use AJAX to handle the upload and display.
Here the user can browse for the file to upload and upload it without the entire page refreshing. Upon a successful upload the section with the upload button and picture will refresh to show the uploaded image...

2. Since an upload button is just a submit button you could put all of the data on one form. (The fields they are filling in and the upload file box). Then you just process all of the data at once and redirect based on which button they click

Here you would essentially have 2 buttons "Submit Data" and "Upload Picture" but they are on the same form. If the user clicks upload it will upload the picture THEN submit the form data if it exists, then refresh to the same page (or somewhere else if you want).

If the user clicks Submit Data, you could assume that they aren't uploading a file (but could check if they did) and handle that form data accordingly.

Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest