Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Warning that a file exists(file upload)

Warning that a file exists(file upload)

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasesysadminhelp
4 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Christer Claesson
    wrote on last edited by
    #1

    Hello there I'm building an application that will allow users to upload files to an online file manager of sorts. I've chosen to store the files in a database and so far I'm satisfied with the solution. However I've encountered a problem with the file upload. I'm using the built in file upload in asp.net 2.0. I would like to warn the user that a file with that name already exists and prompt a popup with an Ok(to overwrite) and Cancel(abort upload). This is the classic client/server side problem though I guess, but even if I've looked around for a solution for a while I have not found any. And I'm sure I'm not the first with this problem. Any suggestions/links on how to solve this? Regards Christer Claesson

    G 1 Reply Last reply
    0
    • C Christer Claesson

      Hello there I'm building an application that will allow users to upload files to an online file manager of sorts. I've chosen to store the files in a database and so far I'm satisfied with the solution. However I've encountered a problem with the file upload. I'm using the built in file upload in asp.net 2.0. I would like to warn the user that a file with that name already exists and prompt a popup with an Ok(to overwrite) and Cancel(abort upload). This is the classic client/server side problem though I guess, but even if I've looked around for a solution for a while I have not found any. And I'm sure I'm not the first with this problem. Any suggestions/links on how to solve this? Regards Christer Claesson

      G Offline
      G Offline
      g00fyman
      wrote on last edited by
      #2

      The way i achieve this is to use my asp:message box (a custom control) and return a warning to the user, because the control is server based i can act on the events at the server and not have to rely on javascript, the other way is just to rename the file (and, if you choose) maintain a mapping in your database. the mapping is extra overhead and not really required unless you must have the filename they uploaded. regs, g00fy

      C 1 Reply Last reply
      0
      • G g00fyman

        The way i achieve this is to use my asp:message box (a custom control) and return a warning to the user, because the control is server based i can act on the events at the server and not have to rely on javascript, the other way is just to rename the file (and, if you choose) maintain a mapping in your database. the mapping is extra overhead and not really required unless you must have the filename they uploaded. regs, g00fy

        C Offline
        C Offline
        Christer Claesson
        wrote on last edited by
        #3

        Thank you for your reply. This custom control, is it open source and avaliable for others? Due to space issue I would like to overwrite files and not store double(or more) copies of each file. Regards Christer

        G 1 Reply Last reply
        0
        • C Christer Claesson

          Thank you for your reply. This custom control, is it open source and avaliable for others? Due to space issue I would like to overwrite files and not store double(or more) copies of each file. Regards Christer

          G Offline
          G Offline
          g00fyman
          wrote on last edited by
          #4

          it is still in beta, but will be available soon for a small cost. the other option you have is to do a quick if(File.Exists()) { } and if true then display a button on the page that confirms the overwrite of the file. This way on the first postback you could upload the file and name it like ~filename.ext. If the answer is no then either force them to click a No button and delete the temp file or just delete it on next file upload and check. the latter option would require maintaining a list of files to be deleted, else you could have concurrency problems if this is a multi user application. regards, g00fy

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups