HELP ASP coding problem.

My Friend wrote me a file upload script in ASP(I've no programming skill) and he's on vacation now; that works great however I need to change the filename when it upload(now it use the file name + aa if duplicate) so I just wondering if anyone know how to modify the code to make it work?   I want to able to use today's date + sec for the file name when it upload for the file name.
It's not a homework or anything like that if you want I can give you my actual website and see how it look now.


Here's the HTML file code:
<html>
<head>

</head>

<body>

<form name="frmUpload" Method="Post" Enctype="multipart/form-data" Action="UploadAction.asp">
<table>
     <tr>
          <td>File</td>
          <td><input type="file" name="txtFileName"></td>
     </tr>
     <tr>
          <td>File</td>
          <td><input type="file" name="txtFileName1"></td>
     </tr>
     <tr>
          <td>Author</td>
          <td><input type="text" name="txtAuthor"></td>    
     </tr>
     <tr>
          <td>Author</td>
          <td><input type="text" name="txtAuthor1"></td>    
     </tr>
     <TR>
          <td COLSPAN="2" ALIGN="right"><INPUT TYPE="Submit" VALUE="Upload"></TD>
     </TR>
</table>
</form>
</body>
</html>



Here's the uploadaction.asp code:
<%@ Language=VBScript %>

<%
Option explicit
Response.Buffer = True
On Error Resume Next

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

     Dim objUpload
     Dim lngMaxFileBytes
     Dim strUploadPath
     Dim ChangeLine
     Dim overwriteFile
     Dim chgFileName
     Dim limitFileType(2)
     Dim varResult

     lngMaxFileBytes = 600000
     strUploadPath = "c:\images"
     changeLine = "true"
     overwriteFile = "aa"
     chgFileName = ""
     'limitFileType(0) = "bmp"
     'limitFileType(1) = "jpg"
     'limitFileType(2) = "gif"

     
     Set objUpload = Server.CreateObject("chk.slfUpload")

     If Err.Number <> 0 Then

          Response.Write "The component wasn't registered"

     Else
          varResult = objUpload.DoUpload (lngMaxFileBytes, strUploadPath, changeLine, overwriteFile, chgFileName, limitFileType)
          Set objUpload = Nothing

          'Write the result
          Dim i
          For i = 0 to UBound(varResult,1)
               Response.Write varResult(i,0) & " : " & varResult(i,1) & "<br>"
          Next

     End If

End If
%>


Thanks.
LVL 9
pcchiuAsked:
Who is Participating?
 
fritz_the_blankCommented:
Okay and good luck.

FtB
0
 
fritz_the_blankCommented:
for the overwrite, you could just do:

overwriteFile = Now() & ""


as for changing the name of the file at upload, I can only take a guess since I can't see the code for the component:


chgFileName = Now() & ""


FtB
0
 
pcchiuAuthor Commented:
It give me Error : Bad file name or number after the put in the overwriteFile = Now() & ""
and  Microsoft VBScript compilation error '800a03ea'
for chgFileName = Now() &

Actually I've no problem for the overwriteFile and the whole thing I want is to change the filename before it get upload to the server so the user can not use the fxxk.jpg or some bad name for the file and I may use the number for the filename once I found out how it works.

Hmmm that's the two files and the .dll file from my friend and he won't be back until the next month...

Thanks for your help.   Also I can increase the points if anyone can solve that for me.



0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
fritz_the_blankCommented:
The problem is that I can't see the code for the .dll.

0
 
fritz_the_blankCommented:
One other option is to use a different upload component:

http://www.taka.nl/programming/asp/comparing_fileupload.asp
0
 
fritz_the_blankCommented:
0
 
pcchiuAuthor Commented:
I don't think I can see the code from the .dll either only the one have the orginial file can do that?  
O well how about is there any FREE asp upload coding around the world is easy to use just like that one upload form and one asp form and one dll?  

Thanks.
0
 
fritz_the_blankCommented:
>>I don't think I can see the code from the .dll either only the one have the orginial file can do that?  <<

That is correct.

>>O well how about is there any FREE asp upload coding around the world is easy to use just like that one upload form and one asp form and one dll? <<

 
http://aspalliance.com/dundas/default.aspx
0
 
pcchiuAuthor Commented:
Yes the aspalliance.com/dundas/default.aspx look cool and let me read all the doc and see if I can change the filename somehow.

Thanks.
0
 
pcchiuAuthor Commented:
I've it installed and the sample was running great.   However I still can not figure out how to rename the file to the filename I want before it put to the server...  A little help will be great.  I increase the point to 150.   The only thing is I need the file under specific name before it get to the server or I don't mind to change it(automatically) after it get upload to the server.

Thanks.
0
 
pcchiuAuthor Commented:
OK I'm not that lazy.   I found the way to use the form to pass a value and insert it as a filename.   Thanks for the software FtB.

0
 
fritz_the_blankCommented:
I am sorry to take so long to get back--I teach all day at the university on Tuesdays & Thursdays. I am happy that you have this resolved.

FtB
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.