Refresh Image After Upload

Refresh Image After Upload

  

Hi all,

i got some problem in developing application, i need refresh image after upload.

But the application stuck in no file selected after i upload the photo. I have 2 condition change photo and upload. In change photo condition the image can change photo smoothly. But in upload condition it stuck.

Image :

Condition :


Thanks.

So what is the If Surrounding the File Upload widget? Are you trying to then display the photo instead of the upload widget?

After you select upload and it refreshes, it is supposed to go back to no file selected, as this file has already been submitted to the server.

Jordan Welch wrote:

So what is the If Surrounding the File Upload widget? Are you trying to then display the photo instead of the upload widget?

After you select upload and it refreshes, it is supposed to go back to no file selected, as this file has already been submitted to the server.

Hi Jordan,

i already try like this :

it still fail, after i upload the image it won't refresh to the image i uploaded.

Where do you set the widget's image to the new source? Do you need a refresh data? Or is it assigning it straight to the content on the page?

I'm missing a lot of information, if you post an OML this could be easier to solve.

Jordan Welch wrote:

Where do you set the widget's image to the new source? Do you need a refresh data? Or is it assigning it straight to the content on the page?

I'm missing a lot of information, if you post an OML this could be easier to solve.

Hi jordan,

this is the oml.

Hope you can help me.


thanks.


Solution

Okay I was able to get the picture to refresh and show correctly with these steps.

1. Your IF is showing the picture only if the record in the form has an ID. However, you never assigned the ID from the newly created Picture back to the record. so I added that. Here is that assignment node

2. Then you need to make sure that you are refreshing a container OUTSIDE the if. If you just refresh the picture, it won't work because it is still not being shown from the If. I gave the outer container a name and set the Ajax Refresh to that.

That should work for you!

Moving forward some tips:

In the save action, you need to set the NewsPicture's NewsID to the News.Id or it will not load next time you open the page. Right now they are not being associated to each other.

You should set the delete rule of the NewsPicture.NewsId to Delete, or you will no longer be able to delete news articles with pictures, it will throw a SQL error


Last: If a person uploads a picture and doesn't save the news article, this picture will remain uploaded and stored while associated with no news piece because it never got a NewsId. You could put a delete in the cancel operation, but that will only work if they hit cancel and not just close the browser.

I recommend changing the page a bit so that they can only upload a picture once the initial News entity is saved. You can also then immediately set the Pictures NewsId upon upload.


Hope this advice made sense. 

Good luck and keep at it!


Solution

Jordan Welch wrote:

Okay I was able to get the picture to refresh and show correctly with these steps.

1. Your IF is showing the picture only if the record in the form has an ID. However, you never assigned the ID from the newly created Picture back to the record. so I added that. Here is that assignment node

2. Then you need to make sure that you are refreshing a container OUTSIDE the if. If you just refresh the picture, it won't work because it is still not being shown from the If. I gave the outer container a name and set the Ajax Refresh to that.

That should work for you!

Moving forward some tips:

In the save action, you need to set the NewsPicture's NewsID to the News.Id or it will not load next time you open the page. Right now they are not being associated to each other.

You should set the delete rule of the NewsPicture.NewsId to Delete, or you will no longer be able to delete news articles with pictures, it will throw a SQL error


Last: If a person uploads a picture and doesn't save the news article, this picture will remain uploaded and stored while associated with no news piece because it never got a NewsId. You could put a delete in the cancel operation, but that will only work if they hit cancel and not just close the browser.

I recommend changing the page a bit so that they can only upload a picture once the initial News entity is saved. You can also then immediately set the Pictures NewsId upon upload.


Hope this advice made sense. 

Good luck and keep at it!


Hi jordan,

thanks for your advice. I already learn from your advice and it's work.

See you on top.