Click to See Complete Forum and Search --> : Change name on ASPUploaded file


Odlaren
11-17-2009, 01:21 PM
I am using ASPUpload to put image files om the server. Now the user puts his file with whatever name. I want to let the asp pages give the files name of the users member names, i.e. 245.jpg... 1245.jpg and so on.

I thought of changing the names in an asp page with help of FileSystemObject but the problem is to know which file was uploaded. Especially if more than one user is uploading simoultanesly.

Does anyone have a tip to help med solve this problem?

/ Rolf

yamaharuss
11-17-2009, 03:22 PM
http://support.persits.com/show.asp?code=PS02041192

Odlaren
11-17-2009, 06:40 PM
It seems very difficult to me. I have tried both versions in the link but cannot get it work. Even the Response.Write "NewName:" and so on doesn't give the desired output.

I used File.Copy(Server.MapPath("bilder") & NewName to put it a folder below the asp pages. The picture file with the original name got uploaded, but not deleted. And as mentioned the copied file did not get uploaded.

Could it possible be that I have only one file to upload and therefore did not use the For-Next loop, just the lines inbetween?

Rolf

yamaharuss
11-19-2009, 08:06 AM
post your code

Odlaren
11-19-2009, 11:04 AM
I have now got it working. The problem before was that there did exist a file with that name. And therefore the move command did not work in this case. So, when I first deleted the old file I could rename the new one with that move command.

I thank you for your first tip. It did work under the right circumstances.

But now I have another problem with this: After uploading and renaming the image file, my program jumps back to an earlier asp page but the new image does not show up there. Although I have written Response.Expires = -1440 on top of the code. Not even if I put the cursor in the address field of the browser and hit enter. But it works if I update the browser with F5.

I thought the expires command should force an update and not let the cached page show up again.

Any ideas how I should do?

/ Rolf

yamaharuss
11-19-2009, 03:49 PM
Response.Expires is not enough. Google "asp browser caching"

Odlaren
11-19-2009, 06:06 PM
After going through the tips and information that I found on Google, many people say that the following lines would do the trick:

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

.. and some more. But it did not help all those who got this information, nor did it work for me either. Some people say there that it is not possible to clear the cached images.

So I guess that there actually is no cure to this...?

Rolf

yamaharuss
11-20-2009, 11:14 AM
There is always a cure. I'm not so sure yours is a cache issue.. but if it is you can always add a unique querystring tag to be sure you get a fresh page.

yourpage.asp?somestring=someuniquevalue

Odlaren
11-20-2009, 01:27 PM
I do use: Response.Redirect "kunder.asp?kundid=3" and did also think that this would update the entire page. When I do this type of jumps all the new text will be updated, but it seems not to happen when an image with the same name as before is updated. Even if the image size and date is changed.

Rolf

yamaharuss
11-20-2009, 01:30 PM
Try:

Function uniqueid()
Dim theseconds
theseconds=DateDiff("s", "01/01/2000 12:00:00 AM", Date() & " " & Time())
uniqueid=theseconds
End Function

Response.Redirect "kunder.asp?kundid=3&UID="&uniqueid

Odlaren
11-20-2009, 02:42 PM
I tried, but sorry, the same result as before.

Rolf

Odlaren
11-22-2009, 09:08 AM
Maybe it isn't a cache problem as you wrote. I thought so before, but now I don't know. After installing Mozilla Firefox 3.5 I tested and then it updates as it should. And I have checked the cache is enabled in FF. But IE 7 doesn't update.

Is there an ASP command to force the page to reload from server?

/ Rolf