Multiple File Timestamp

Last post 02-08-2012, 2:02 PM by foolishmortal. 8 replies.
Sort Posts: Previous Next
  •  01-10-2012, 9:15 AM 72591

    Multiple File Timestamp

    I've read various posts similar to my issue, but none identical.
     
    I need to regularly update a file with the same name (a page calling it is looking for a particular file name). When a new one is uploaded, it doesn't overwrite the old one; it is the original filename_timestamp. This causes the prior file to have to be manually deleted first, which isn't very convenient. I just want an existing file automatically overwritten if a new one is uploaded with the same filename.
     
    I saw some code in another thread about checking if the file exists, but I'm not sure where that check should take place. Hoping there is a setting somewhere that will do this automatically. Any help would be greatly appreciated! 
  •  01-10-2012, 3:58 PM 72599 in reply to 72591

    Re: Multiple File Timestamp

    Hi Foolishmortal,
     
    The example below shows you how to use the "CopyTo" method to save the upload file. This method will overwrite the exists file.
     
    <%@ Language="VBScript" %>
    <!-- #include file="aspuploader/include_aspuploader.asp" -->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>
    Form - Single File Upload
    </title>
    </head>
    <body>
    <div class="demo">
                            
            <h2>Single File Upload</h2>
    <p> A basic sample demonstrating the use of the Upload control.</p>
    <!-- do not need enctype="multipart/form-data" -->
    <form id="form1" method="POST">
    <%
    Dim uploader
    Set uploader=new AspUploader
    uploader.MaxSizeKB=10240
    uploader.Name="myuploader"
    uploader.InsertText="Upload File (Max 10M)"
    uploader.MultipleFilesUpload=true
    %>
    <%=uploader.GetString() %>
    </form>
    <br/><br/>
    <%
    If Request.Form("myuploader")&""<>"" Then
    Dim mvcfile
    Set mvcfile=uploader.GetUploadedFile(Request.Form("myuploader"))
        mvcfile.CopyTo("C:\inetpub\wwwroot\aspuploader\photos\"+mvcfile.FileName)
    End If
    %>
    </div>
    </body>
    </html>
     
    Regards,
     
    Ken 
     
     
  •  01-11-2012, 8:53 AM 72629 in reply to 72599

    Re: Multiple File Timestamp

    Perfect, thanks for the help!
  •  02-06-2012, 3:45 PM 72937 in reply to 72629

    Re: Multiple File Timestamp

    I thought this had it working, but now when duplicate files are uploaded, nothing happens. They are shown as successfully uploaded, but no overwriting at all is taking place; the original file remains with no showing of the new file on the server. 
     
    CodeL
    1.       <h2>Select one or more files to upload.</h2>  
    2. <p> </p>  
    3.           
    4.             <form id="form1" method="POST">  
    5.             <%  
    6.             Dim uploader  
    7.             Set uploader=new AspUploader  
    8.             uploader.MaxSizeKB=10240  
    9.             uploader.Name="myuploader"  
    10.             uploader.InsertText="Upload File (Max 10M)"  
    11.             uploader.MultipleFilesUpload=true  
    12.             uploader.AllowedFileExtensions="*.mp4"  
    13.             %>  
    14.             <%=uploader.GetString() %>  
    15.             </form>  
    16.               
    17.             <br/><br/>  
    18. <%  
    19.   
    20. If Request.Form("myuploader")&""<>"" Then  
    21.     Dim mvcfile  
    22.     Set mvcfile=uploader.GetUploadedFile(Request.Form("myuploader"))  
    23.         pth="c:\inetpub\..."+mvcfile.FileName  
    24.         mvcfile.CopyTo(pth)  
    25. End If  
    26.   
    27. %>  
     
  •  02-07-2012, 6:42 AM 72941 in reply to 72937

    Re: Multiple File Timestamp

    Hi foolishmortal,
     
    Please use the full path, not ... and ensure that your site has the write/read permission of the location you set.
     
    Regards,
     
    Ken 
  •  02-07-2012, 8:27 AM 72943 in reply to 72941

    Re: Multiple File Timestamp

    I'm using the full path; I simply hid it for security. Also, the directory has proper permissions. I can upload fine, except when replacing a file with a new one of the same filename. 
  •  02-07-2012, 8:58 AM 72945 in reply to 72943

    Re: Multiple File Timestamp

    After more debugging, the "If Request.Form("myuploader")&""<>"" Then" is never firing; I put an "else" and it fires every time. I'm using the code shown above... any ideas?
     
    Thanks 
  •  02-08-2012, 7:43 AM 72956 in reply to 72945

    Re: Multiple File Timestamp

    Hi foolishmortal,
     
    Please try demo http://aspuploader.com/demo/form-singlefile.asp. You can find the source code of this page in the asp uploader download package.
     
    Test it on your end please. Does the  If Request.Form("myuploader") work on that example page?
     
    Regards,
     
    Ken 
  •  02-08-2012, 2:02 PM 72961 in reply to 72956

    Re: Multiple File Timestamp

    While I got the If... to fire, it still didn't work. Then I realized the code you posted that I had copied had a "+" instead of "&" when appending the filename to the path. I fixed that and it did the trick. thanks for all of your help. 
View as RSS news feed in XML