2
I have a field called img, in it I save the image name, for example: 001.jpg, where "1" corresponds to the record ID.
I have a routine that changes the image and is working, the change is made by jQuery and ASP.
But when I change the image, the routine saves with the same name, that is, deletes the previous image and saves the new one with the same name: 001.jpg
That’s where the problem is: I change the attribute src
via jQuery, is working because I put a test and changed the name, but the name is not changed and only the image in the folder.
That is, as the src
is not changed the image also does not change.
And if I change the name of the image in the database gives in the same, because imagine the situation:
figura atual: 001.jpg
figura nova : 001-x.jpg
There in the bank was the last and when I go to make the change, again will be changed to 001-x.jpg or will never change the attribute src
.
Am I logical or missing something?
What I’ve already done:
$.ajax({ url: "usuarios-acoes.asp?IdReg=" + IdReg + "&Acao=" + Acao + "&nomeUsu=" + nomeUsu, dataType: "html", success: function(result) { if (result == "N") {} else { $('#IdUsuarioImg').val(''); $('#titNomeModalImg').html(''); $('#img-peq-usu-' + IdReg).attr('src', result); $('#img-gde-usu-' + IdReg).attr('src', result); } }, error: function() { $('#IdUsuarioImg').val(''); $('#titNomeModalImg').html(''); } });
My goal is to show the new image that has just been saved. When I save the image I return to the ajax only the name and change the attr src. that is the system change 001.jpg to 001.jpg, but the image is different. I didn’t understand what you posted, could give me a light ?
– Ronaldo Bueno
Do you need to save the image by putting an id on it and then show it? You can put the code you’ve already done to understand its logic ?
– Gabriel Rodrigues
Delete the comment and edit your post by placing your code you can use <pre> code </pre> to highlight and indent
– Gabriel Rodrigues
The save code is only the Upload and then I give a Sponse that is caught by ajax <pre> $. ajax({ url: "usuarios-acoes.Asp? Idreg="+Idreg+"&Acao="+Acao+"&nomeUsu="+nomeUsu, dataType: "html", Success: Function(result){ if(result == "N"){ } Else{ $('#Idusuarioimg'). val(''); $('#titNomeModalImg'). html('); $('#img-peq-Usu-'+Idreg). attr('src', result); $('#img-gde-Usu-'+Idreg). attr('src', result); } }, error: Function(){ $('#Idusuarioimg'). val('); $('#titNomeModalImg'). html('); } }); </pre>
– Ronaldo Bueno
I cannot use your example 1 because the "00" are not fixed, it increases. in my code has the result variable, in it I return the image name, so I’m already doing your example 2, agree ? and in both cases did not solve, the script changes the name of the image, but my problem is that before it had an image and now it is another figure but with the same name.
– Ronaldo Bueno
Instead of getting Id Get the name of the whole picture
– Gabriel Rodrigues
Let’s go continue this discussion in chat.
– Gabriel Rodrigues
but I’m not taking the ID, just an example, I’m taking the name of the image to show in the result
– Ronaldo Bueno