Detecting if an uploaded file already exists

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Detecting if an uploaded file already exists

Larry Brindise
I looked but don't see if there is a way to control whether a file that has been uploaded with the same name to the same location overwrites the old version, etc.  Is there any way to check for this before beginning the upload so that the user wouldn't have to wait for the entire upload to complete before the code runs and can check?  (e.g., System.IO.FileInfo.Exists  can be checked before the upload begins?)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Detecting if an uploaded file already exists

Dean Brettle
Administrator
First, for most applications, if the file already exists the desired behavior is to give the user the oppurtunity to pick a new name.  If that's the desired behavior for your app, you'd implement it by moving the file to a temporary unique name while you prompt the user for the new name.  Once you have the new name, you'd move the file to that name.

If you have an application where that isn't the appropriate behavior, and you really want to reject the request earlier, you'll need to use the latest development snapshot, and write your own custom UploadStorageProvider.  For details, see the docs/Manual.html included in the snapshot and let me know if you have any questions.
Loading...