Ok, a user in the system which profile has been stored in the database including the path of his photo is viewing his particular. ie: name, address, phone number, his picture, etc. This user wish to change his current photo posted before. Thus, a HTML FileField is provided for him to browse the image and save it into our server. What i want to do is, when a user click on the Update button. The older picture shown in the page will be replaced with his newly given picture. The path of the picture stored in server is successfully updated. And I set the code to retrieve this user's profile including his picture from the database again after the Update button is clicked. I've tested the code by Updating picture and certain information, i noticed that all information can be updated and replacing the old information on the screen except that the picture did not change to the newly added picture in the database. Any idea...?
Try to add this to your page:
<meta http-equiv="Expires" content="0" />
Thanks PaaB. But it's not working. Where do i put that line anyway. I put it in between <HEAD> and </HEAD>. Am i right?
Yes it is the right place.
Can you show the source code.
When user chnege the image, is then changed path and name of the picture? I think about that when would be changed only path and not name of the picture then IE possibly use picture saved on client computer?
As i mentioned earlier. I have a HTML FileField where user can browse image and update it. the system will then saved the image into the server and update the directory stored in database. Finally, the system should display the latest image newly added by this user, but it is not. The path and directory of new image is updated in the database. same goes to the image saved in the server. I don't know if i'm right. if wrong, please correct me. i think that the system take the same image downloaded previously in temp folder. and if i'm right, is there any method that i can call client computer to download the image again? Please advise...Thank u
What object do you use for display picture - Image Web Control or Image Html Element? Do you update the ImageUrl/src parameter on the "uploading" postback?
I'm using Html element. After the new image has been saved on the server and its directory in the database. User can choose to view the same info again by a single click. Thus, i recall the sub that display the information once again. the code for image is like this.
myCommand =New SqlCommand("SELECT * FROM User_Profile WHERE ([User_ID] = '" & userid & "' AND [Company_ID] = '" & compid & "')", myConnection)
myReader = myCommand.ExecuteReader
myReader.Read()
imgUser.Src = myReader.Item("Photo")
thats it.. any mistake on this one?
This isn't related to your image issue, but you should be using Parameters with your SQL statement:
myCommand =NewSqlCommand("SELECT * FROM User_Profile WHERE ([User_ID] = @.user_id AND [Company_ID] = @.company_id ')",myConnection)
myCommand.Parameters.Add(New SqlParameter("@.user_id",SqlDbType.Integer)).Value = userid
myCommand.Parameters.Add(New SqlParameter("@.company_id",SqlDbType.Integer)).Value = compid
tried your suggestion, but it's not working. And even other information also is not displaying. i know the usage of parameters, usually i used it with stored procedure. there's nothing wrong with plain sql command compare with 1 that using parameter right?
nickless1 wrote:
imgUser.Src = myReader.Item("Photo")
You might try this to see if it makes a difference:
imgUser.Src = myReader.Item("Photo") & "?" & System.DateTime.Now().ToString()Also, see this KB article:IIS: How to Disable Caching of Specific MIME Types
nickless1 wrote:
tried your suggestion, but it's not working. And even other informationalso is not displaying. i know the usage of parameters, usually i usedit with stored procedure. there's nothing wrong with plain sql commandcompare with 1 that using parameter right?
Sorry, I shouldn't have confused the issue. To protect yourself fromSQL injectionyou should always use parameters in SQL statements; you should neverconcatenate user-supplied data to a string to be executed. Ididn't meant to introduce another problem, however. Once you havesolved your image caching problem you can post another question aboutthe parameter problem.
Yes...It works. Thanks a lot. I couldn't open the page u gave. Would u mind to explain how it works? Thanks again...
I'm glad that approach worked for you. (And I've now corrected the link that I posted.)
Hi,
Im having kind of the same problem you have. Could you explain how you managed to solve it? as you might now, this issue is a brainbuster! :S
0 comments:
Post a Comment