0

I have a file called img.gif. With fileupload, it does not seem to be uploading the new file properly as the old .gif still exist.

FileUpld.SaveAs(uploadfile);

Any ideas?

4
  • I doubt that problem is in FileUpload, I have tested this scenario and it works like it should. Why do you think that there is a problem with uploading? Is uploaded file then hosted in IIS process? Commented Nov 28, 2012 at 17:08
  • As FileUpld.SaveAs captures the file path and I selected an image that was different. What else can it be? Commented Nov 28, 2012 at 17:28
  • There are 2 options possible. First IIS locked the file because it's beeing served so FileUpload can't save over opened file. Second is that you are looking at cached response from IIS. Check uploaded file on server file system. I think you are looking at second option. Commented Nov 28, 2012 at 17:37
  • You are right. It was a cached version. Commented Nov 28, 2012 at 18:38

1 Answer 1

2

When I was facing this type of problem I always rename my file name as auto-increment from 1 to n.
i.e. img1.gif, img2.gif, img3.gif.
Try this one may be this one is helpful.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I need it to be the same name though as the system looks for the same name.
Then replace your current file by your new file but not automatically, use System.IO for this operation.Hay do one thing, FIRST when you uploading a file and it is in you folder where you store uploaded files than delete the previous one. SECOND now store your new file where you want to store.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.