SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    upload img fails when having the same name

    hey all,
    in my form where ppl can update stuff, there's an option to replace an image with a new one, however, when the image has the same name, the image fails to upload (the old image stays) when pressing the upload button, altho all rest of the infos are uploaded correctly.

    here's the code
    Code ASP:
    Set fso = server.CreateObject("Scripting.FileSystemObject")
    Folder = Server.MapPath("photos")
    ssql = "Select FileName from Animals where FileID=" & session("id")
    rs.Open ssql, Conn, 3, 3
    if size > 0 then ' if something has been uploaded
    Pic1 = rs("FileName") ' get the current image in the db to be deleted
    if Pic1 <> "" then ' if there's image inside the db then deleting it
    Set MyFile = fso.GetFile(Server.Mappath("photos") & pic1)
    MyFile.Delete
    set MyFile = nothing
    end if
    FileName = Upload.UniqueName(folder, FileName) ' get the new image name & path to upload
    Upload("File1").SaveAs Folder & FileName ' saving
    ssql2 = "update Animals set FileName=""" & FileName & """ where FileID=" & session("id") ' updating new name in DB
    Conn.execute ssql2
    end if

    whats wrong?
    thanks...

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "upload" is not part of classic ASP.

    Contact the developer of the upload code and ask them why it fails.

  3. #3
    SitePoint Addict itHighway's Avatar
    Join Date
    Jan 2008
    Location
    GUJ
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are using third party component than there must be a command to overwrite existing image. Mostly in third party components overwrite method is ON by default.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •